cypress 5.2.0 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var minimist = require('minimist');
3
+ const minimist = require('minimist');
4
4
 
5
- var debug = require('debug')('cypress:cli');
5
+ const debug = require('debug')('cypress:cli');
6
6
 
7
- var args = minimist(process.argv.slice(2));
7
+ const args = minimist(process.argv.slice(2));
8
8
 
9
- var util = require('./lib/util'); // we're being used from the command line
9
+ const util = require('./lib/util'); // we're being used from the command line
10
10
 
11
11
 
12
12
  switch (args.exec) {
@@ -15,7 +15,7 @@ switch (args.exec) {
15
15
 
16
16
  require('./lib/tasks/install').start({
17
17
  force: args.force
18
- })["catch"](util.logErrorExit1);
18
+ }).catch(util.logErrorExit1);
19
19
 
20
20
  break;
21
21
 
@@ -26,7 +26,7 @@ switch (args.exec) {
26
26
  require('./lib/tasks/verify').start({
27
27
  force: true
28
28
  }) // always force verification
29
- ["catch"](util.logErrorExit1);
29
+ .catch(util.logErrorExit1);
30
30
 
31
31
  break;
32
32
 
package/lib/cli.js CHANGED
@@ -1,53 +1,33 @@
1
1
  "use strict";
2
2
 
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ const _ = require('lodash');
4
4
 
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ const R = require('ramda');
6
6
 
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
7
+ const commander = require('commander');
8
8
 
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
+ const {
10
+ stripIndent
11
+ } = require('common-tags');
10
12
 
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ const logSymbols = require('log-symbols');
12
14
 
13
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ const debug = require('debug')('cypress:cli:cli');
14
16
 
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+ const util = require('./util');
16
18
 
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+ const logger = require('./logger');
18
20
 
19
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
21
+ const errors = require('./errors');
20
22
 
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
-
23
- var _ = require('lodash');
24
-
25
- var R = require('ramda');
26
-
27
- var commander = require('commander');
28
-
29
- var _require = require('common-tags'),
30
- stripIndent = _require.stripIndent;
31
-
32
- var logSymbols = require('log-symbols');
33
-
34
- var debug = require('debug')('cypress:cli:cli');
35
-
36
- var util = require('./util');
37
-
38
- var logger = require('./logger');
39
-
40
- var errors = require('./errors');
41
-
42
- var cache = require('./tasks/cache'); // patch "commander" method called when a user passed an unknown option
23
+ const cache = require('./tasks/cache'); // patch "commander" method called when a user passed an unknown option
43
24
  // we want to print help for the current command and exit with an error
44
25
 
45
26
 
46
- function unknownOption(flag) {
47
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'option';
27
+ function unknownOption(flag, type = 'option') {
48
28
  if (this._allowUnknownOption) return;
49
29
  logger.error();
50
- logger.error(" error: unknown ".concat(type, ":"), flag);
30
+ logger.error(` error: unknown ${type}:`, flag);
51
31
  logger.error();
52
32
  this.outputHelp();
53
33
  util.exit(1);
@@ -55,19 +35,36 @@ function unknownOption(flag) {
55
35
 
56
36
  commander.Command.prototype.unknownOption = unknownOption;
57
37
 
58
- var coerceFalse = function coerceFalse(arg) {
38
+ const coerceFalseOrString = arg => {
39
+ return arg !== 'false' ? arg : false;
40
+ };
41
+
42
+ const coerceFalse = arg => {
59
43
  return arg !== 'false';
60
44
  };
61
45
 
62
- var coerceAnyStringToInt = function coerceAnyStringToInt(arg) {
46
+ const coerceAnyStringToInt = arg => {
63
47
  return typeof arg === 'string' ? parseInt(arg) : arg;
64
48
  };
65
49
 
66
- var spaceDelimitedArgsMsg = function spaceDelimitedArgsMsg(flag, args) {
67
- var msg = "\n ".concat(logSymbols.warning, " Warning: It looks like you're passing --").concat(flag, " a space-separated list of arguments:\n\n \"").concat(args.join(' '), "\"\n\n This will work, but it's not recommended.\n\n If you are trying to pass multiple arguments, separate them with commas instead:\n cypress run --").concat(flag, " arg1,arg2,arg3\n ");
50
+ const spaceDelimitedArgsMsg = (flag, args) => {
51
+ let msg = `
52
+ ${logSymbols.warning} Warning: It looks like you're passing --${flag} a space-separated list of arguments:
53
+
54
+ "${args.join(' ')}"
55
+
56
+ This will work, but it's not recommended.
57
+
58
+ If you are trying to pass multiple arguments, separate them with commas instead:
59
+ cypress run --${flag} arg1,arg2,arg3
60
+ `;
68
61
 
69
62
  if (flag === 'spec') {
70
- msg += "\n The most common cause of this warning is using an unescaped glob pattern. If you are\n trying to pass a glob pattern, escape it using quotes:\n cypress run --spec \"**/*.spec.js\"\n ";
63
+ msg += `
64
+ The most common cause of this warning is using an unescaped glob pattern. If you are
65
+ trying to pass a glob pattern, escape it using quotes:
66
+ cypress run --spec "**/*.spec.js"
67
+ `;
71
68
  }
72
69
 
73
70
  logger.log();
@@ -75,30 +72,28 @@ var spaceDelimitedArgsMsg = function spaceDelimitedArgsMsg(flag, args) {
75
72
  logger.log();
76
73
  };
77
74
 
78
- var parseVariableOpts = function parseVariableOpts(fnArgs, args) {
79
- var _fnArgs = _slicedToArray(fnArgs, 2),
80
- opts = _fnArgs[0],
81
- unknownArgs = _fnArgs[1];
75
+ const parseVariableOpts = (fnArgs, args) => {
76
+ const [opts, unknownArgs] = fnArgs;
82
77
 
83
78
  if (unknownArgs && unknownArgs.length && (opts.spec || opts.tag)) {
84
79
  // this will capture space-delimited args after
85
80
  // flags that could have possible multiple args
86
81
  // but before the next option
87
82
  // --spec spec1 spec2 or --tag foo bar
88
- var multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
83
+ const multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
89
84
 
90
- _.forEach(multiArgFlags, function (flag) {
91
- var argIndex = _.indexOf(args, "--".concat(flag)) + 2;
85
+ _.forEach(multiArgFlags, flag => {
86
+ const argIndex = _.indexOf(args, `--${flag}`) + 2;
92
87
 
93
- var nextOptOffset = _.findIndex(_.slice(args, argIndex), function (arg) {
88
+ const nextOptOffset = _.findIndex(_.slice(args, argIndex), arg => {
94
89
  return _.startsWith(arg, '--');
95
90
  });
96
91
 
97
- var endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
92
+ const endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
98
93
 
99
- var maybeArgs = _.slice(args, argIndex, endIndex);
94
+ const maybeArgs = _.slice(args, argIndex, endIndex);
100
95
 
101
- var extraArgs = _.intersection(maybeArgs, unknownArgs);
96
+ const extraArgs = _.intersection(maybeArgs, unknownArgs);
102
97
 
103
98
  if (extraArgs.length) {
104
99
  opts[flag] = [opts[flag]].concat(extraArgs);
@@ -109,18 +104,20 @@ var parseVariableOpts = function parseVariableOpts(fnArgs, args) {
109
104
  }
110
105
 
111
106
  debug('variable-length opts parsed %o', {
112
- args: args,
113
- opts: opts
107
+ args,
108
+ opts
114
109
  });
115
110
  return util.parseOpts(opts);
116
111
  };
117
112
 
118
- var descriptions = {
113
+ const descriptions = {
119
114
  browserOpenMode: 'path to a custom browser to be added to the list of available browsers in Cypress',
120
115
  browserRunMode: 'runs Cypress in the browser with the given name. if a filesystem path is supplied, Cypress will attempt to use the browser at that path.',
121
116
  cacheClear: 'delete all cached binaries',
117
+ cachePrune: 'deletes all cached binaries except for the version currently in use',
122
118
  cacheList: 'list cached binary versions',
123
119
  cachePath: 'print the path to the binary cache',
120
+ cacheSize: 'Used with the list command to show the sizes of the cached folders',
124
121
  ciBuildId: 'the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers',
125
122
  config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.',
126
123
  configFile: 'path to JSON file where configuration values are set. defaults to "cypress.json". pass "false" to disable.',
@@ -145,11 +142,11 @@ var descriptions = {
145
142
  tag: 'named tag(s) for recorded runs in the Cypress Dashboard',
146
143
  version: 'prints Cypress version'
147
144
  };
148
- var knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'verify', '-v', '--version', 'version', 'info'];
145
+ const knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'verify', '-v', '--version', 'version', 'info'];
149
146
 
150
- var text = function text(description) {
147
+ const text = description => {
151
148
  if (!descriptions[description]) {
152
- throw new Error("Could not find description for: ".concat(description));
149
+ throw new Error(`Could not find description for: ${description}`);
153
150
  }
154
151
 
155
152
  return descriptions[description];
@@ -161,16 +158,15 @@ function includesVersion(args) {
161
158
 
162
159
  function showVersions() {
163
160
  debug('printing Cypress version');
164
- return require('./exec/versions').getVersions().then(function () {
165
- var versions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
166
- logger.always('Cypress package version:', versions["package"]);
161
+ return require('./exec/versions').getVersions().then((versions = {}) => {
162
+ logger.always('Cypress package version:', versions.package);
167
163
  logger.always('Cypress binary version:', versions.binary);
168
164
  process.exit(0);
169
- })["catch"](util.logErrorExit1);
165
+ }).catch(util.logErrorExit1);
170
166
  }
171
167
 
172
- var createProgram = function createProgram() {
173
- var program = new commander.Command(); // bug in commander not printing name
168
+ const createProgram = () => {
169
+ const program = new commander.Command(); // bug in commander not printing name
174
170
  // in usage help docs
175
171
 
176
172
  program._name = 'cypress';
@@ -178,7 +174,7 @@ var createProgram = function createProgram() {
178
174
  return program;
179
175
  };
180
176
 
181
- var addCypressRunCommand = function addCypressRunCommand(program) {
177
+ const addCypressRunCommand = program => {
182
178
  return program.command('run').usage('[options]').description('Runs Cypress tests from the CLI without the GUI').option('-b, --browser <browser-name-or-path>', text('browserRunMode')).option('--ci-build-id <id>', text('ciBuildId')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).option('-e, --env <env>', text('env')).option('--group <name>', text('group')).option('-k, --key <record-key>', text('key')).option('--headed', text('headed')).option('--headless', text('headless')).option('--no-exit', text('exit')).option('--parallel', text('parallel')).option('-p, --port <port>', text('port')).option('-P, --project <project-path>', text('project')).option('-q, --quiet', text('quiet')).option('--record [bool]', text('record'), coerceFalse).option('-r, --reporter <reporter>', text('reporter')).option('-o, --reporter-options <reporter-options>', text('reporterOptions')).option('-s, --spec <spec>', text('spec')).option('-t, --tag <tag>', text('tag')).option('--dev', text('dev'), coerceFalse);
183
179
  };
184
180
  /**
@@ -190,13 +186,13 @@ var addCypressRunCommand = function addCypressRunCommand(program) {
190
186
  */
191
187
 
192
188
 
193
- var castCypressRunOptions = function castCypressRunOptions(opts) {
189
+ const castCypressRunOptions = opts => {
194
190
  // only properties that have type "string | false" in our TS definition
195
191
  // require special handling, because CLI parsing takes care of purely
196
192
  // boolean arguments
197
- var result = R.evolve({
193
+ const result = R.evolve({
198
194
  port: coerceAnyStringToInt,
199
- configFile: coerceFalse
195
+ configFile: coerceFalseOrString
200
196
  })(opts);
201
197
  return result;
202
198
  };
@@ -209,8 +205,8 @@ module.exports = {
209
205
  * const options = parseRunCommand(['cypress', 'run', '--browser', 'chrome'])
210
206
  * // options is {browser: 'chrome'}
211
207
  */
212
- parseRunCommand: function parseRunCommand(args) {
213
- return new Promise(function (resolve, reject) {
208
+ parseRunCommand(args) {
209
+ return new Promise((resolve, reject) => {
214
210
  if (!Array.isArray(args)) {
215
211
  return reject(new Error('Expected array of arguments'));
216
212
  } // make a copy of the input arguments array
@@ -218,19 +214,15 @@ module.exports = {
218
214
  // also remove "cypress" keyword at the start if present
219
215
 
220
216
 
221
- var cliArgs = args[0] === 'cypress' ? _toConsumableArray(args.slice(1)) : _toConsumableArray(args);
217
+ const cliArgs = args[0] === 'cypress' ? [...args.slice(1)] : [...args];
222
218
  cliArgs.unshift(null, null);
223
219
  debug('creating program parser');
224
- var program = createProgram();
225
- addCypressRunCommand(program).action(function () {
226
- for (var _len = arguments.length, fnArgs = new Array(_len), _key = 0; _key < _len; _key++) {
227
- fnArgs[_key] = arguments[_key];
228
- }
229
-
220
+ const program = createProgram();
221
+ addCypressRunCommand(program).action((...fnArgs) => {
230
222
  debug('parsed Cypress run %o', fnArgs);
231
- var options = parseVariableOpts(fnArgs, cliArgs);
223
+ const options = parseVariableOpts(fnArgs, cliArgs);
232
224
  debug('parsed options %o', options);
233
- var casted = castCypressRunOptions(options);
225
+ const casted = castCypressRunOptions(options);
234
226
  debug('casted options %o', casted);
235
227
  resolve(casted);
236
228
  });
@@ -242,76 +234,95 @@ module.exports = {
242
234
  /**
243
235
  * Parses the command line and kicks off Cypress process.
244
236
  */
245
- init: function init(args) {
237
+ init(args) {
246
238
  if (!args) {
247
239
  args = process.argv;
248
240
  }
249
241
 
250
- var CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV;
242
+ const {
243
+ CYPRESS_INTERNAL_ENV
244
+ } = process.env;
251
245
 
252
246
  if (!util.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
253
247
  debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
254
- return errors.exitWithError(errors.errors.invalidCypressEnv)("CYPRESS_INTERNAL_ENV=".concat(CYPRESS_INTERNAL_ENV));
248
+ return errors.exitWithError(errors.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
255
249
  }
256
250
 
257
251
  if (util.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
258
252
  debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
259
- var msg = "\n ".concat(logSymbols.warning, " Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=").concat(CYPRESS_INTERNAL_ENV, "\n\n The environment variable \"CYPRESS_INTERNAL_ENV\" is reserved and should only be used internally.\n\n Unset the \"CYPRESS_INTERNAL_ENV\" environment variable and run Cypress again.\n ");
253
+ let msg = `
254
+ ${logSymbols.warning} Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}
255
+
256
+ The environment variable "CYPRESS_INTERNAL_ENV" is reserved and should only be used internally.
257
+
258
+ Unset the "CYPRESS_INTERNAL_ENV" environment variable and run Cypress again.
259
+ `;
260
260
  logger.log();
261
261
  logger.warn(stripIndent(msg));
262
262
  logger.log();
263
263
  }
264
264
 
265
- var program = createProgram();
266
- program.command('help').description('Shows CLI help and exits').action(function () {
265
+ const program = createProgram();
266
+ program.command('help').description('Shows CLI help and exits').action(() => {
267
267
  program.help();
268
268
  });
269
269
  program.option('-v, --version', text('version')).command('version').description(text('version')).action(showVersions);
270
- addCypressRunCommand(program).action(function () {
271
- for (var _len2 = arguments.length, fnArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
272
- fnArgs[_key2] = arguments[_key2];
273
- }
274
-
270
+ addCypressRunCommand(program).action((...fnArgs) => {
275
271
  debug('running Cypress with args %o', fnArgs);
276
272
 
277
- require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit)["catch"](util.logErrorExit1);
273
+ require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit).catch(util.logErrorExit1);
278
274
  });
279
- program.command('open').usage('[options]').description('Opens Cypress in the interactive GUI.').option('-b, --browser <browser-path>', text('browserOpenMode')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).option('-d, --detached [bool]', text('detached'), coerceFalse).option('-e, --env <env>', text('env')).option('--global', text('global')).option('-p, --port <port>', text('port')).option('-P, --project <project-path>', text('project')).option('--dev', text('dev'), coerceFalse).action(function (opts) {
275
+ program.command('open').usage('[options]').description('Opens Cypress in the interactive GUI.').option('-b, --browser <browser-path>', text('browserOpenMode')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).option('-d, --detached [bool]', text('detached'), coerceFalse).option('-e, --env <env>', text('env')).option('--global', text('global')).option('-p, --port <port>', text('port')).option('-P, --project <project-path>', text('project')).option('--dev', text('dev'), coerceFalse).action(opts => {
280
276
  debug('opening Cypress');
281
277
 
282
- require('./exec/open').start(util.parseOpts(opts))["catch"](util.logErrorExit1);
278
+ require('./exec/open').start(util.parseOpts(opts)).catch(util.logErrorExit1);
283
279
  });
284
- program.command('install').usage('[options]').description('Installs the Cypress executable matching this package\'s version').option('-f, --force', text('forceInstall')).action(function (opts) {
285
- require('./tasks/install').start(util.parseOpts(opts))["catch"](util.logErrorExit1);
280
+ program.command('install').usage('[options]').description('Installs the Cypress executable matching this package\'s version').option('-f, --force', text('forceInstall')).action(opts => {
281
+ require('./tasks/install').start(util.parseOpts(opts)).catch(util.logErrorExit1);
286
282
  });
287
- program.command('verify').usage('[options]').description('Verifies that Cypress is installed correctly and executable').option('--dev', text('dev'), coerceFalse).action(function (opts) {
288
- var defaultOpts = {
283
+ program.command('verify').usage('[options]').description('Verifies that Cypress is installed correctly and executable').option('--dev', text('dev'), coerceFalse).action(opts => {
284
+ const defaultOpts = {
289
285
  force: true,
290
286
  welcomeMessage: false
291
287
  };
292
- var parsedOpts = util.parseOpts(opts);
288
+ const parsedOpts = util.parseOpts(opts);
293
289
 
294
- var options = _.extend(parsedOpts, defaultOpts);
290
+ const options = _.extend(parsedOpts, defaultOpts);
295
291
 
296
- require('./tasks/verify').start(options)["catch"](util.logErrorExit1);
292
+ require('./tasks/verify').start(options).catch(util.logErrorExit1);
297
293
  });
298
- program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).action(function (opts, args) {
294
+ program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).option('prune', text('cachePrune')).option('--size', text('cacheSize')).action(function (opts, args) {
299
295
  if (!args || !args.length) {
300
296
  this.outputHelp();
301
297
  util.exit(1);
302
298
  }
303
299
 
304
- var _args = _slicedToArray(args, 1),
305
- command = _args[0];
300
+ const [command] = args;
306
301
 
307
- if (!_.includes(['list', 'path', 'clear'], command)) {
308
- unknownOption.call(this, "cache ".concat(command), 'command');
302
+ if (!_.includes(['list', 'path', 'clear', 'prune'], command)) {
303
+ unknownOption.call(this, `cache ${command}`, 'command');
304
+ }
305
+
306
+ if (command === 'list') {
307
+ debug('cache command %o', {
308
+ command,
309
+ size: opts.size
310
+ });
311
+ return cache.list(opts.size).catch({
312
+ code: 'ENOENT'
313
+ }, () => {
314
+ logger.always('No cached binary versions were found.');
315
+ process.exit(0);
316
+ }).catch(e => {
317
+ debug('cache list command failed with "%s"', e.message);
318
+ util.logErrorExit1(e);
319
+ });
309
320
  }
310
321
 
311
322
  cache[command]();
312
323
  });
313
- program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(function (opts) {
314
- require('./exec/info').start(opts).then(util.exit)["catch"](util.logErrorExit1);
324
+ program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(opts => {
325
+ require('./exec/info').start(opts).then(util.exit).catch(util.logErrorExit1);
315
326
  });
316
327
  debug('cli starts with arguments %j', args);
317
328
  util.printNodeOptions(); // if there are no arguments
@@ -321,11 +332,11 @@ module.exports = {
321
332
  program.help(); // exits
322
333
  }
323
334
 
324
- var firstCommand = args[2];
335
+ const firstCommand = args[2];
325
336
 
326
337
  if (!_.includes(knownCommands, firstCommand)) {
327
338
  debug('unknown command %s', firstCommand);
328
- logger.error('Unknown command', "\"".concat(firstCommand, "\""));
339
+ logger.error('Unknown command', `"${firstCommand}"`);
329
340
  program.outputHelp();
330
341
  return util.exit(1);
331
342
  }
@@ -341,6 +352,7 @@ module.exports = {
341
352
  debug('program parsing arguments');
342
353
  return program.parse(args);
343
354
  }
355
+
344
356
  };
345
357
 
346
358
  if (!module.parent) {
package/lib/cypress.js CHANGED
@@ -1,51 +1,49 @@
1
1
  "use strict";
2
2
 
3
3
  // https://github.com/cypress-io/cypress/issues/316
4
- var Promise = require('bluebird');
4
+ const Promise = require('bluebird');
5
5
 
6
- var tmp = Promise.promisifyAll(require('tmp'));
6
+ const tmp = Promise.promisifyAll(require('tmp'));
7
7
 
8
- var fs = require('./fs');
8
+ const fs = require('./fs');
9
9
 
10
- var _open = require('./exec/open');
10
+ const open = require('./exec/open');
11
11
 
12
- var _run = require('./exec/run');
12
+ const run = require('./exec/run');
13
13
 
14
- var util = require('./util');
14
+ const util = require('./util');
15
15
 
16
- var cli = require('./cli');
16
+ const cli = require('./cli');
17
17
 
18
- var cypressModuleApi = {
18
+ const cypressModuleApi = {
19
19
  /**
20
20
  * Opens Cypress GUI
21
21
  * @see https://on.cypress.io/module-api#cypress-open
22
22
  */
23
- open: function open() {
24
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
+ open(options = {}) {
25
24
  options = util.normalizeModuleOptions(options);
26
- return _open.start(options);
25
+ return open.start(options);
27
26
  },
28
27
 
29
28
  /**
30
29
  * Runs Cypress tests in the current project
31
30
  * @see https://on.cypress.io/module-api#cypress-run
32
31
  */
33
- run: function run() {
34
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
-
36
- if (!_run.isValidProject(options.project)) {
37
- return Promise.reject(new Error("Invalid project path parameter: ".concat(options.project)));
32
+ run(options = {}) {
33
+ if (!run.isValidProject(options.project)) {
34
+ return Promise.reject(new Error(`Invalid project path parameter: ${options.project}`));
38
35
  }
39
36
 
40
37
  options = util.normalizeModuleOptions(options);
41
- return tmp.fileAsync().then(function (outputPath) {
38
+ return tmp.fileAsync().then(outputPath => {
42
39
  options.outputPath = outputPath;
43
- return _run.start(options).then(function (failedTests) {
40
+ return run.start(options).then(failedTests => {
44
41
  return fs.readJsonAsync(outputPath, {
45
- "throws": false
46
- }).then(function (output) {
42
+ throws: false
43
+ }).then(output => {
47
44
  if (!output) {
48
45
  return {
46
+ status: 'failed',
49
47
  failures: failedTests,
50
48
  message: 'Could not find Cypress test run results'
51
49
  };
@@ -56,6 +54,7 @@ var cypressModuleApi = {
56
54
  });
57
55
  });
58
56
  },
57
+
59
58
  cli: {
60
59
  /**
61
60
  * Parses CLI arguments into an object that you can pass to "cypress.run"
@@ -67,9 +66,10 @@ var cypressModuleApi = {
67
66
  * await cypress.run(options)
68
67
  * @see https://on.cypress.io/module-api
69
68
  */
70
- parseRunArguments: function parseRunArguments(args) {
69
+ parseRunArguments(args) {
71
70
  return cli.parseRunCommand(args);
72
71
  }
72
+
73
73
  }
74
74
  };
75
75
  module.exports = cypressModuleApi;