mirror of https://github.com/lukechilds/docs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
6 years ago
|
'use strict';
|
||
|
|
||
|
var debug = require('debug')('cypress:cli');
|
||
|
var util = require('../util');
|
||
|
var spawn = require('./spawn');
|
||
|
var verify = require('../tasks/verify');
|
||
|
|
||
|
module.exports = {
|
||
|
start: function start() {
|
||
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||
|
|
||
|
if (!util.isInstalledGlobally() && !options.global && !options.project) {
|
||
|
options.project = process.cwd();
|
||
|
}
|
||
|
|
||
|
var args = [];
|
||
|
|
||
|
if (options.env) {
|
||
|
args.push('--env', options.env);
|
||
|
}
|
||
|
|
||
|
if (options.config) {
|
||
|
args.push('--config', options.config);
|
||
|
}
|
||
|
|
||
|
if (options.port) {
|
||
|
args.push('--port', options.port);
|
||
|
}
|
||
|
|
||
|
if (options.project) {
|
||
|
args.push('--project', options.project);
|
||
|
}
|
||
|
|
||
|
debug('opening from options %j', options);
|
||
|
debug('command line arguments %j', args);
|
||
|
|
||
|
function open() {
|
||
|
return spawn.start(args, {
|
||
|
dev: options.dev,
|
||
|
detached: Boolean(options.detached),
|
||
|
stdio: 'inherit'
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (options.dev) {
|
||
|
return open();
|
||
|
}
|
||
|
|
||
|
return verify.start().then(open);
|
||
|
}
|
||
|
};
|