Merge pull request #173 from cypress-io/attach-cypress

Attach cypress by default, use `--detached` CLI flag to get old behavior
This commit is contained in:
Brian Mann
2017-06-20 16:33:48 -04:00
committed by GitHub
5 changed files with 17 additions and 6 deletions
+7 -2
View File
@@ -2,20 +2,25 @@ const minimist = require('minimist')
const debug = require('debug')('cypress:cli')
const args = minimist(process.argv.slice(2))
const reportError = (err) => {
console.error(err) // eslint-disable-line no-console
process.exit(1)
}
// we're being used from the command line
switch (args.exec) {
case 'install':
debug('installing Cypress from NPM')
require('./lib/download')
.install()
.catch(console.error) // eslint-disable-line no-console
.catch(reportError)
break
case 'verify':
// for simple testing in the monorepo
debug('verifying Cypress')
require('./lib/download/utils')
.verify()
.catch(console.error) // eslint-disable-line no-console
.catch(reportError)
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: true,
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')
+1 -1
View File
@@ -20,7 +20,7 @@ describe('exec open', function () {
it('calls spawn with correct options', function () {
return open.start().then(() => {
expect(spawn.start).to.be.calledWith([], {
detached: true,
detached: false,
stdio: ['ignore', 'ignore', 'ignore'],
})
})