cli: add --detached mode

This commit is contained in:
Gleb Bahmutov
2017-06-20 11:56:49 -04:00
parent 82e8fe395c
commit 9b28249152
4 changed files with 14 additions and 4 deletions
+5 -1
View File
@@ -1,5 +1,6 @@
const minimist = require('minimist')
const debug = require('debug')('cypress:cli')
const _ = require('lodash')
const args = minimist(process.argv.slice(2))
const reportError = (err) => {
@@ -23,8 +24,11 @@ switch (args.exec) {
.catch(reportError)
break
case 'open':
// require('./lib/exec/open').start()
_.remove(process.argv, (arg) => arg === '--exec')
debug('opening Cypress application')
require('./lib/exec/open').start()
debug('CLI arguments', process.argv)
require('./lib/cli').init()
break
default:
// export our node module interface
+5 -1
View File
@@ -1,12 +1,13 @@
const _ = require('lodash')
const commander = require('commander')
const { oneLine } = require('common-tags')
const debug = require('debug')('cypress:cli')
const coerceFalse = (arg) => {
return arg !== 'false'
}
const parseOpts = (opts) => _.pick(opts, 'spec', 'reporter', 'reporterOptions', 'path', 'destination', 'port', 'env', 'cypressVersion', 'config', 'record', 'key', 'browser')
const parseOpts = (opts) => _.pick(opts, 'spec', 'reporter', 'reporterOptions', 'path', 'destination', 'port', 'env', 'cypressVersion', 'config', 'record', 'key', 'browser', 'detached')
const descriptions = {
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',
@@ -21,6 +22,7 @@ const descriptions = {
runs Cypress in the browser with the given name.
note: using an external browser will cancel video recording of tests.
`,
detached: 'runs Cypress application in detached mode',
}
const text = (description) => {
@@ -57,6 +59,7 @@ module.exports = {
.option('-p, --port <port>', text('port'))
.option('-e, --env <env>', text('env'))
.option('-c, --config <config>', text('config'))
.option('-d, --detached [bool]', text('detached'), coerceFalse)
.action((opts) => require('./exec/open').start(parseOpts(opts)))
program
@@ -69,6 +72,7 @@ module.exports = {
.description('Verifies that Cypress is installed correctly and executable')
.action(() => require('./download/utils').verify({ force: true }))
debug('cli starts with arguments %j', process.argv)
program.parse(process.argv)
//# if the process.argv.length
+4 -1
View File
@@ -1,5 +1,6 @@
const downloadUtils = require('../download/utils')
const spawn = require('./spawn')
const debug = require('debug')('cypress:cli')
module.exports = {
start (options = {}) {
@@ -16,11 +17,13 @@ module.exports = {
if (options.port) {
args.push('--port', options.port)
}
debug('opening from options %j', options)
debug('command line arguments %j', args)
return downloadUtils.verify()
.then(() => {
return spawn.start(args, {
detached: false,
detached: Boolean(options.detached),
stdio: ['ignore', 'ignore', 'ignore'],
})
})
-1
View File
@@ -1,6 +1,5 @@
const _ = require('lodash')
const cp = require('child_process')
// const chalk = require('chalk')
const Promise = require('bluebird')
const debug = require('debug')('cypress:cli')