1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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
This commit is contained in:
Kenneth Auchenberg 2017-11-20 06:51:46 -08:00 committed by Tim Neutkens
parent c6d9ab7563
commit 20af8cdabe

View file

@ -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)