mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-05 06:40:56 -06:00
chore: make NODE_OPTIONS fork with --inspect args (#7711)
This commit is contained in:
@@ -27,6 +27,15 @@ export function needsOptions (): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current inspect flag, if the process was launched with one.
|
||||
*/
|
||||
function getCurrentInspectFlag (): string | undefined {
|
||||
const flag = process.execArgv.find((v) => v.startsWith('--inspect'))
|
||||
|
||||
return flag ? flag.split('=')[0] : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Fork the current process using the good NODE_OPTIONS and pipe stdio
|
||||
* through the current process. On exit, copy the error code too.
|
||||
@@ -41,9 +50,16 @@ export function forkWithCorrectOptions (): void {
|
||||
ORIGINAL_NODE_OPTIONS: process.env.ORIGINAL_NODE_OPTIONS,
|
||||
})
|
||||
|
||||
const launchArgs = process.argv.slice(1)
|
||||
const inspectFlag = getCurrentInspectFlag()
|
||||
|
||||
if (inspectFlag) {
|
||||
launchArgs.unshift(`${inspectFlag}=${process.debugPort + 1}`)
|
||||
}
|
||||
|
||||
cp.spawn(
|
||||
process.execPath,
|
||||
process.argv.slice(1),
|
||||
launchArgs,
|
||||
{ stdio: 'inherit' },
|
||||
)
|
||||
.on('error', () => {})
|
||||
|
||||
Reference in New Issue
Block a user