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:
parent
c6d9ab7563
commit
20af8cdabe
9
bin/next
9
bin/next
|
@ -27,13 +27,18 @@ const commands = new Set([
|
||||||
])
|
])
|
||||||
|
|
||||||
let cmd = process.argv[2]
|
let cmd = process.argv[2]
|
||||||
let args
|
let args = []
|
||||||
|
let nodeArgs = []
|
||||||
|
|
||||||
if (new Set(['--version', '-v']).has(cmd)) {
|
if (new Set(['--version', '-v']).has(cmd)) {
|
||||||
console.log(`next.js v${pkg.version}`)
|
console.log(`next.js v${pkg.version}`)
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (new Set(process.argv).has('--inspect')) {
|
||||||
|
nodeArgs.push('--inspect')
|
||||||
|
}
|
||||||
|
|
||||||
if (new Set(['--help', '-h']).has(cmd)) {
|
if (new Set(['--help', '-h']).has(cmd)) {
|
||||||
console.log(`
|
console.log(`
|
||||||
Usage
|
Usage
|
||||||
|
@ -61,7 +66,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || defaultEnv
|
||||||
const bin = join(__dirname, 'next-' + cmd)
|
const bin = join(__dirname, 'next-' + cmd)
|
||||||
|
|
||||||
const startProcess = () => {
|
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) => {
|
proc.on('close', (code, signal) => {
|
||||||
if (code !== null) {
|
if (code !== null) {
|
||||||
process.exit(code)
|
process.exit(code)
|
||||||
|
|
Loading…
Reference in a new issue