Unverified Commit e95030b5 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update to have default value for renderToHTML (#6755)

* Update to have default value for renderToHTML
options in dev mode

* Update test
parent 6716bcbf
...@@ -114,7 +114,7 @@ export default class DevServer extends Server { ...@@ -114,7 +114,7 @@ export default class DevServer extends Server {
return !snippet.includes('data-amp-development-mode-only') return !snippet.includes('data-amp-development-mode-only')
} }
async renderToHTML (req, res, pathname, query, options) { async renderToHTML (req, res, pathname, query, options = {}) {
const compilationErr = await this.getCompilationError(pathname) const compilationErr = await this.getCompilationError(pathname)
if (compilationErr) { if (compilationErr) {
res.statusCode = 500 res.statusCode = 500
......
...@@ -32,7 +32,7 @@ const startServer = async (optEnv = {}) => { ...@@ -32,7 +32,7 @@ const startServer = async (optEnv = {}) => {
optEnv optEnv
) )
server = await initNextServerScript(scriptPath, /Ready on/, env) server = await initNextServerScript(scriptPath, /Ready on/, env, /ReferenceError: options is not defined/)
} }
describe('Custom Server', () => { describe('Custom Server', () => {
......
...@@ -17,7 +17,7 @@ import _pkg from 'next/package.json' ...@@ -17,7 +17,7 @@ import _pkg from 'next/package.json'
export const nextServer = server export const nextServer = server
export const pkg = _pkg export const pkg = _pkg
export function initNextServerScript (scriptPath, successRegexp, env) { export function initNextServerScript (scriptPath, successRegexp, env, failRegexp) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const instance = spawn('node', [scriptPath], { env }) const instance = spawn('node', [scriptPath], { env })
...@@ -30,7 +30,12 @@ export function initNextServerScript (scriptPath, successRegexp, env) { ...@@ -30,7 +30,12 @@ export function initNextServerScript (scriptPath, successRegexp, env) {
} }
function handleStderr (data) { function handleStderr (data) {
process.stderr.write(data.toString()) const message = data.toString()
if (failRegexp && failRegexp.test(message)) {
instance.kill()
return reject(new Error('received failRegexp'))
}
process.stderr.write(message)
} }
instance.stdout.on('data', handleStdout) instance.stdout.on('data', handleStdout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment