mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-05 05:59:49 -06:00
- fixes #1264 - fixes #1321 - fixes #1799 - fixes #2689 - fixes #2688 - fixes #2687 - fixes #2686
31 lines
768 B
JavaScript
31 lines
768 B
JavaScript
const cp = require('child_process')
|
|
const path = require('path')
|
|
const chalk = require('chalk')
|
|
const finder = require('find-package-json')
|
|
|
|
const DEFAULT_SCRIPT = 'npm run test -- --inspect-brk=5566'
|
|
|
|
const file = process.argv[2]
|
|
|
|
// walks up from the file until it finds the first
|
|
// package.json in a parent folder
|
|
const { value: pkg, filename } = finder(file).next()
|
|
|
|
const script = pkg.scripts['test-debug'] || DEFAULT_SCRIPT
|
|
|
|
const [cmd, ...args] = script.split(' ')
|
|
|
|
const log = (k, v) => {
|
|
// eslint-disable-next-line
|
|
console.log(chalk.yellow(k), chalk.cyan(v))
|
|
}
|
|
|
|
log('Node version:', process.version)
|
|
log('Debug script:', script)
|
|
log('Debugging test file:', file)
|
|
|
|
cp.spawn(cmd, args.concat(file), {
|
|
cwd: path.dirname(filename),
|
|
stdio: 'inherit',
|
|
})
|