Commit 20af8cda authored by Kenneth Auchenberg's avatar Kenneth Auchenberg Committed by Tim Neutkens

Add option to pass --inspect flag to enable server-side debugging (#3294)

* Add option to pass --inspect flag

* Re-add shebang's

* Tweak spacing

* Use global 'node' when spawning process
parent c6d9ab75
......@@ -27,13 +27,18 @@ const commands = new Set([
])
let cmd = process.argv[2]
let args
let args = []
let nodeArgs = []
if (new Set(['--version', '-v']).has(cmd)) {
console.log(`next.js v${pkg.version}`)
process.exit(0)
}
if (new Set(process.argv).has('--inspect')) {
nodeArgs.push('--inspect')
}
if (new Set(['--help', '-h']).has(cmd)) {
console.log(`
Usage
......@@ -61,7 +66,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || defaultEnv
const bin = join(__dirname, 'next-' + cmd)
const startProcess = () => {
const proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] })
const proc = spawn('node', [...nodeArgs, ...[bin], ...args], { stdio: 'inherit', customFds: [0, 1, 2] })
proc.on('close', (code, signal) => {
if (code !== null) {
process.exit(code)
......
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