Files
cypress/scripts/debug.js
Zach Bloomquist 5a0d8b5cfe Allow passing a list of space-separated specs to --spec (#3375)
* cli: add otherSpecs for varargs [wip]

* scripts: pass command-line args through to debugged command

* cli: parse space-delimited specs

* cli: undo unneeded

* cli: cleaned up parseVariableOpts, added warning

* cli: cleanup

* cli: add tests

* cli: glorious whitespace

* cli: a more robust test

* cli: better snapshot

* server: strip single-quotes around --spec arg

#2298
2019-03-15 00:42:46 -04:00

37 lines
747 B
JavaScript

const cp = require('child_process')
const chalk = require('chalk')
const pkg = require('../package.json')
const INSPECT_PORT = 5566
const script = process.argv[2]
if (!script) {
throw new Error('Missing script argument')
}
const pkgScript = pkg.scripts[script]
if (!pkgScript) {
throw new Error(`package.json scripts not found for script: ${script}`)
}
const [cmd, ...args] = pkgScript.split(' ')
const userArgs = process.argv.slice(3)
args.unshift(`--inspect-brk=${INSPECT_PORT}`)
args.push(...userArgs)
const log = (k, v) => {
// eslint-disable-next-line
console.log(chalk.yellow(k), chalk.cyan(v))
}
log('Node:', process.version)
log('Script:', script)
log('Spawning:', pkgScript)
cp.spawn(cmd, args, {
stdio: 'inherit',
})