cypress 5.1.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +6 -6
- package/lib/cli.js +114 -107
- package/lib/cypress.js +21 -21
- package/lib/errors.js +233 -276
- package/lib/exec/info.js +29 -32
- package/lib/exec/open.js +7 -8
- package/lib/exec/run.js +20 -20
- package/lib/exec/spawn.js +53 -49
- package/lib/exec/versions.js +18 -17
- package/lib/exec/xvfb.js +43 -37
- package/lib/fs.js +1 -1
- package/lib/logger.js +24 -50
- package/lib/tasks/cache.js +96 -36
- package/lib/tasks/download.js +113 -133
- package/lib/tasks/get-folder-size.js +41 -0
- package/lib/tasks/install.js +225 -161
- package/lib/tasks/state.js +54 -56
- package/lib/tasks/unzip.js +72 -69
- package/lib/tasks/verify.js +112 -147
- package/lib/util.js +172 -176
- package/package.json +3 -3
- package/types/cypress-npm-api.d.ts +13 -5
- package/types/cypress.d.ts +51 -48
- package/types/mocha/index.d.ts +123 -308
- package/types/net-stubbing.ts +169 -19
package/lib/tasks/install.js
CHANGED
@@ -1,126 +1,159 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
var data = _taggedTemplateLiteral(["\n ", " Warning: Forcing a binary version different than the default.\n\n The CLI expected to install version: ", "\n\n Instead we will install version: ", "\n\n These versions may not work properly together.\n "]);
|
3
|
+
const _ = require('lodash');
|
5
4
|
|
6
|
-
|
7
|
-
return data;
|
8
|
-
};
|
5
|
+
const os = require('os');
|
9
6
|
|
10
|
-
|
11
|
-
}
|
7
|
+
const url = require('url');
|
12
8
|
|
13
|
-
|
14
|
-
var data = _taggedTemplateLiteral(["\n Cypress ", " is installed in ", "\n "]);
|
9
|
+
const path = require('path');
|
15
10
|
|
16
|
-
|
17
|
-
return data;
|
18
|
-
};
|
11
|
+
const chalk = require('chalk');
|
19
12
|
|
20
|
-
|
21
|
-
}
|
13
|
+
const debug = require('debug')('cypress:cli');
|
22
14
|
|
23
|
-
|
24
|
-
var data = _taggedTemplateLiteral(["\n Failed to access ", ":\n\n ", "\n "]);
|
15
|
+
const Listr = require('listr');
|
25
16
|
|
26
|
-
|
27
|
-
return data;
|
28
|
-
};
|
17
|
+
const verbose = require('@cypress/listr-verbose-renderer');
|
29
18
|
|
30
|
-
|
31
|
-
}
|
19
|
+
const Promise = require('bluebird');
|
32
20
|
|
33
|
-
|
34
|
-
var data = _taggedTemplateLiteral(["\n ", " Overriding Cypress cache directory to: ", "\n\n Previous installs of Cypress may not be found.\n "]);
|
21
|
+
const logSymbols = require('log-symbols');
|
35
22
|
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
const {
|
24
|
+
stripIndent
|
25
|
+
} = require('common-tags');
|
39
26
|
|
40
|
-
|
41
|
-
}
|
27
|
+
const fs = require('../fs');
|
42
28
|
|
43
|
-
|
44
|
-
var data = _taggedTemplateLiteral(["\n ", " Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0."]);
|
29
|
+
const download = require('./download');
|
45
30
|
|
46
|
-
|
47
|
-
return data;
|
48
|
-
};
|
31
|
+
const util = require('../util');
|
49
32
|
|
50
|
-
|
51
|
-
}
|
33
|
+
const state = require('./state');
|
52
34
|
|
53
|
-
|
54
|
-
var data = _taggedTemplateLiteral(["\n ", " Warning: It looks like you've installed Cypress globally.\n\n This will work, but it's not recommended.\n\n The recommended way to install Cypress is as a devDependency per project.\n\n You should probably run these commands:\n\n - ", "\n - ", "\n "], ["\n ", " Warning: It looks like you\\'ve installed Cypress globally.\n\n This will work, but it'\\s not recommended.\n\n The recommended way to install Cypress is as a devDependency per project.\n\n You should probably run these commands:\n\n - ", "\n - ", "\n "]);
|
35
|
+
const unzip = require('./unzip');
|
55
36
|
|
56
|
-
|
57
|
-
return data;
|
58
|
-
};
|
37
|
+
const logger = require('../logger');
|
59
38
|
|
60
|
-
|
61
|
-
|
39
|
+
const {
|
40
|
+
throwFormErrorText,
|
41
|
+
errors
|
42
|
+
} = require('../errors');
|
62
43
|
|
63
|
-
|
64
|
-
|
44
|
+
const getNpmArgv = () => {
|
45
|
+
const json = process.env.npm_config_argv;
|
65
46
|
|
66
|
-
|
67
|
-
return
|
68
|
-
}
|
47
|
+
if (!json) {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
|
51
|
+
debug('found npm argv json %o', json);
|
69
52
|
|
70
|
-
|
71
|
-
|
53
|
+
try {
|
54
|
+
return JSON.parse(json).original || [];
|
55
|
+
} catch (e) {
|
56
|
+
return [];
|
57
|
+
}
|
58
|
+
}; // attempt to discover the version specifier used to install Cypress
|
59
|
+
// for example: "^5.0.0", "https://cdn.cypress.io/...", ...
|
72
60
|
|
73
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
74
61
|
|
75
|
-
|
62
|
+
const getVersionSpecifier = (startDir = path.resolve(__dirname, '../..')) => {
|
63
|
+
const argv = getNpmArgv();
|
76
64
|
|
77
|
-
|
65
|
+
if (argv) {
|
66
|
+
const tgz = _.find(argv, t => t.endsWith('cypress.tgz'));
|
78
67
|
|
79
|
-
|
68
|
+
if (tgz) {
|
69
|
+
return tgz;
|
70
|
+
}
|
71
|
+
}
|
80
72
|
|
81
|
-
|
73
|
+
const getVersionSpecifierFromPkg = dir => {
|
74
|
+
debug('looking for versionSpecifier %o', {
|
75
|
+
dir
|
76
|
+
});
|
82
77
|
|
83
|
-
|
78
|
+
const tryParent = () => {
|
79
|
+
const parentPath = path.resolve(dir, '..');
|
84
80
|
|
85
|
-
|
81
|
+
if (parentPath === dir) {
|
82
|
+
debug('reached FS root with no versionSpecifier found');
|
83
|
+
return;
|
84
|
+
}
|
86
85
|
|
87
|
-
|
86
|
+
return getVersionSpecifierFromPkg(parentPath);
|
87
|
+
};
|
88
88
|
|
89
|
-
|
89
|
+
return fs.readJSON(path.join(dir, 'package.json')).catch(() => ({})).then(pkg => {
|
90
|
+
const specifier = _.chain(['dependencies', 'devDependencies', 'optionalDependencies']).map(prop => _.get(pkg, `${prop}.cypress`)).compact().first().value();
|
90
91
|
|
91
|
-
|
92
|
+
return specifier || tryParent();
|
93
|
+
});
|
94
|
+
}; // recurse through parent directories until package.json with `cypress` is found
|
92
95
|
|
93
|
-
var _require = require('common-tags'),
|
94
|
-
stripIndent = _require.stripIndent;
|
95
96
|
|
96
|
-
|
97
|
+
return getVersionSpecifierFromPkg(startDir).then(versionSpecifier => {
|
98
|
+
debug('finished looking for versionSpecifier', {
|
99
|
+
versionSpecifier
|
100
|
+
});
|
101
|
+
return versionSpecifier;
|
102
|
+
});
|
103
|
+
};
|
97
104
|
|
98
|
-
|
105
|
+
const betaNpmUrlRe = /^\/beta\/npm\/(?<version>[0-9.]+)\/(?<artifactSlug>[^/]+)\/cypress\.tgz$/; // convert a prerelease NPM package .tgz URL to the corresponding binary .zip URL
|
99
106
|
|
100
|
-
|
107
|
+
const getBinaryUrlFromPrereleaseNpmUrl = npmUrl => {
|
108
|
+
let parsed;
|
101
109
|
|
102
|
-
|
110
|
+
try {
|
111
|
+
parsed = url.parse(npmUrl);
|
112
|
+
} catch (e) {
|
113
|
+
return;
|
114
|
+
}
|
103
115
|
|
104
|
-
|
116
|
+
const matches = betaNpmUrlRe.exec(parsed.pathname);
|
105
117
|
|
106
|
-
|
118
|
+
if (parsed.hostname !== 'cdn.cypress.io' || !matches) {
|
119
|
+
return;
|
120
|
+
}
|
107
121
|
|
108
|
-
|
109
|
-
|
110
|
-
|
122
|
+
const {
|
123
|
+
version,
|
124
|
+
artifactSlug
|
125
|
+
} = matches.groups;
|
126
|
+
parsed.pathname = `/beta/binary/${version}/${os.platform()}-${os.arch()}/${artifactSlug}/cypress.zip`;
|
127
|
+
return parsed.format();
|
128
|
+
};
|
111
129
|
|
112
|
-
|
130
|
+
const alreadyInstalledMsg = () => {
|
113
131
|
if (!util.isPostInstall()) {
|
114
|
-
logger.log(stripIndent
|
132
|
+
logger.log(stripIndent`
|
133
|
+
Skipping installation:
|
134
|
+
|
135
|
+
Pass the ${chalk.yellow('--force')} option if you'd like to reinstall anyway.
|
136
|
+
`);
|
115
137
|
}
|
116
138
|
};
|
117
139
|
|
118
|
-
|
140
|
+
const displayCompletionMsg = () => {
|
119
141
|
// check here to see if we are globally installed
|
120
142
|
if (util.isInstalledGlobally()) {
|
121
143
|
// if we are display a warning
|
122
144
|
logger.log();
|
123
|
-
logger.warn(stripIndent
|
145
|
+
logger.warn(stripIndent`
|
146
|
+
${logSymbols.warning} Warning: It looks like you\'ve installed Cypress globally.
|
147
|
+
|
148
|
+
This will work, but it'\s not recommended.
|
149
|
+
|
150
|
+
The recommended way to install Cypress is as a devDependency per project.
|
151
|
+
|
152
|
+
You should probably run these commands:
|
153
|
+
|
154
|
+
- ${chalk.cyan('npm uninstall -g cypress')}
|
155
|
+
- ${chalk.cyan('npm install --save-dev cypress')}
|
156
|
+
`);
|
124
157
|
return;
|
125
158
|
}
|
126
159
|
|
@@ -131,52 +164,53 @@ var displayCompletionMsg = function displayCompletionMsg() {
|
|
131
164
|
logger.log();
|
132
165
|
};
|
133
166
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
167
|
+
const downloadAndUnzip = ({
|
168
|
+
version,
|
169
|
+
installDir,
|
170
|
+
downloadDir
|
171
|
+
}) => {
|
172
|
+
const progress = {
|
139
173
|
throttle: 100,
|
140
174
|
onProgress: null
|
141
175
|
};
|
142
|
-
|
143
|
-
|
176
|
+
const downloadDestination = path.join(downloadDir, 'cypress.zip');
|
177
|
+
const rendererOptions = getRendererOptions(); // let the user know what version of cypress we're downloading!
|
144
178
|
|
145
|
-
logger.log(
|
179
|
+
logger.log(`Installing Cypress ${chalk.gray(`(version: ${version})`)}`);
|
146
180
|
logger.log();
|
147
|
-
|
181
|
+
const tasks = new Listr([{
|
148
182
|
title: util.titleize('Downloading Cypress'),
|
149
|
-
task:
|
183
|
+
task: (ctx, task) => {
|
150
184
|
// as our download progresses indicate the status
|
151
|
-
progress.onProgress = progessify(
|
185
|
+
progress.onProgress = progessify(task, 'Downloading Cypress');
|
152
186
|
return download.start({
|
153
|
-
version
|
154
|
-
downloadDestination
|
155
|
-
progress
|
156
|
-
}).then(
|
187
|
+
version,
|
188
|
+
downloadDestination,
|
189
|
+
progress
|
190
|
+
}).then(redirectVersion => {
|
157
191
|
if (redirectVersion) version = redirectVersion;
|
158
|
-
debug(
|
159
|
-
}).then(
|
192
|
+
debug(`finished downloading file: ${downloadDestination}`);
|
193
|
+
}).then(() => {
|
160
194
|
// save the download destination for unzipping
|
161
|
-
util.setTaskTitle(
|
195
|
+
util.setTaskTitle(task, util.titleize(chalk.green('Downloaded Cypress')), rendererOptions.renderer);
|
162
196
|
});
|
163
197
|
}
|
164
198
|
}, unzipTask({
|
165
|
-
progress
|
199
|
+
progress,
|
166
200
|
zipFilePath: downloadDestination,
|
167
|
-
installDir
|
168
|
-
rendererOptions
|
201
|
+
installDir,
|
202
|
+
rendererOptions
|
169
203
|
}), {
|
170
204
|
title: util.titleize('Finishing Installation'),
|
171
|
-
task:
|
172
|
-
|
205
|
+
task: (ctx, task) => {
|
206
|
+
const cleanup = () => {
|
173
207
|
debug('removing zip file %s', downloadDestination);
|
174
208
|
return fs.removeAsync(downloadDestination);
|
175
209
|
};
|
176
210
|
|
177
|
-
return cleanup().then(
|
211
|
+
return cleanup().then(() => {
|
178
212
|
debug('finished installation in', installDir);
|
179
|
-
util.setTaskTitle(
|
213
|
+
util.setTaskTitle(task, util.titleize(chalk.green('Finished Installation'), chalk.gray(installDir)), rendererOptions.renderer);
|
180
214
|
});
|
181
215
|
}
|
182
216
|
}], rendererOptions); // start the tasks!
|
@@ -184,9 +218,7 @@ var downloadAndUnzip = function downloadAndUnzip(_ref) {
|
|
184
218
|
return Promise.resolve(tasks.run());
|
185
219
|
};
|
186
220
|
|
187
|
-
|
188
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
189
|
-
|
221
|
+
const start = (options = {}) => {
|
190
222
|
// handle deprecated / removed
|
191
223
|
if (util.getEnv('CYPRESS_BINARY_VERSION')) {
|
192
224
|
return throwFormErrorText(errors.removed.CYPRESS_BINARY_VERSION)();
|
@@ -202,56 +234,77 @@ var start = function start() {
|
|
202
234
|
force: false
|
203
235
|
});
|
204
236
|
|
205
|
-
|
206
|
-
|
237
|
+
const pkgVersion = util.pkgVersion();
|
238
|
+
let needVersion = pkgVersion;
|
239
|
+
let binaryUrlOverride;
|
207
240
|
debug('version in package.json is', needVersion); // let this environment variable reset the binary version we need
|
208
241
|
|
209
242
|
if (util.getEnv('CYPRESS_INSTALL_BINARY')) {
|
210
243
|
// because passed file paths are often double quoted
|
211
244
|
// and might have extra whitespace around, be robust and trim the string
|
212
|
-
|
213
|
-
|
245
|
+
const trimAndRemoveDoubleQuotes = true;
|
246
|
+
const envVarVersion = util.getEnv('CYPRESS_INSTALL_BINARY', trimAndRemoveDoubleQuotes);
|
214
247
|
debug('using environment variable CYPRESS_INSTALL_BINARY "%s"', envVarVersion);
|
215
248
|
|
216
249
|
if (envVarVersion === '0') {
|
217
250
|
debug('environment variable CYPRESS_INSTALL_BINARY = 0, skipping install');
|
218
|
-
logger.log(stripIndent
|
251
|
+
logger.log(stripIndent`
|
252
|
+
${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`);
|
219
253
|
logger.log();
|
220
254
|
return Promise.resolve();
|
221
|
-
} // if this doesn't match the expected version
|
222
|
-
// then print warning to the user
|
223
|
-
|
224
|
-
|
225
|
-
if (envVarVersion !== needVersion) {
|
226
|
-
// reset the version to the env var version
|
227
|
-
needVersion = envVarVersion;
|
228
255
|
}
|
256
|
+
|
257
|
+
binaryUrlOverride = envVarVersion;
|
229
258
|
}
|
230
259
|
|
231
260
|
if (util.getEnv('CYPRESS_CACHE_FOLDER')) {
|
232
|
-
|
233
|
-
logger.log(stripIndent
|
261
|
+
const envCache = util.getEnv('CYPRESS_CACHE_FOLDER');
|
262
|
+
logger.log(stripIndent`
|
263
|
+
${chalk.yellow('Note:')} Overriding Cypress cache directory to: ${chalk.cyan(envCache)}
|
264
|
+
|
265
|
+
Previous installs of Cypress may not be found.
|
266
|
+
`);
|
234
267
|
logger.log();
|
235
268
|
}
|
236
269
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
return fs.ensureDirAsync(cacheDir)
|
270
|
+
const installDir = state.getVersionDir(pkgVersion);
|
271
|
+
const cacheDir = state.getCacheDir();
|
272
|
+
const binaryDir = state.getBinaryDir(pkgVersion);
|
273
|
+
return fs.ensureDirAsync(cacheDir).catch({
|
241
274
|
code: 'EACCES'
|
242
|
-
},
|
243
|
-
return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent
|
244
|
-
|
245
|
-
|
246
|
-
|
275
|
+
}, err => {
|
276
|
+
return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent`
|
277
|
+
Failed to access ${chalk.cyan(cacheDir)}:
|
278
|
+
|
279
|
+
${err.message}
|
280
|
+
`);
|
281
|
+
}).then(() => {
|
282
|
+
return Promise.all([state.getBinaryPkgVersionAsync(binaryDir), getVersionSpecifier()]);
|
283
|
+
}).then(([binaryVersion, versionSpecifier]) => {
|
284
|
+
if (!binaryUrlOverride && versionSpecifier) {
|
285
|
+
const computedBinaryUrl = getBinaryUrlFromPrereleaseNpmUrl(versionSpecifier);
|
286
|
+
|
287
|
+
if (computedBinaryUrl) {
|
288
|
+
debug('computed binary url from version specifier %o', {
|
289
|
+
computedBinaryUrl,
|
290
|
+
needVersion
|
291
|
+
});
|
292
|
+
binaryUrlOverride = computedBinaryUrl;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
needVersion = binaryUrlOverride || needVersion;
|
297
|
+
debug('installed version is', binaryVersion, 'version needed is', needVersion);
|
298
|
+
|
247
299
|
if (!binaryVersion) {
|
248
300
|
debug('no binary installed under cli version');
|
249
301
|
return true;
|
250
302
|
}
|
251
303
|
|
252
|
-
debug('installed version is', binaryVersion, 'version needed is', needVersion);
|
253
304
|
logger.log();
|
254
|
-
logger.log(stripIndent
|
305
|
+
logger.log(stripIndent`
|
306
|
+
Cypress ${chalk.green(binaryVersion)} is installed in ${chalk.cyan(installDir)}
|
307
|
+
`);
|
255
308
|
logger.log();
|
256
309
|
|
257
310
|
if (options.force) {
|
@@ -266,7 +319,7 @@ var start = function start() {
|
|
266
319
|
}
|
267
320
|
|
268
321
|
return true;
|
269
|
-
}).then(
|
322
|
+
}).then(shouldInstall => {
|
270
323
|
// noop if we've been told not to download
|
271
324
|
if (!shouldInstall) {
|
272
325
|
debug('Not downloading or installing binary');
|
@@ -274,19 +327,27 @@ var start = function start() {
|
|
274
327
|
}
|
275
328
|
|
276
329
|
if (needVersion !== pkgVersion) {
|
277
|
-
logger.log(chalk.yellow(stripIndent
|
330
|
+
logger.log(chalk.yellow(stripIndent`
|
331
|
+
${logSymbols.warning} Warning: Forcing a binary version different than the default.
|
332
|
+
|
333
|
+
The CLI expected to install version: ${chalk.green(pkgVersion)}
|
334
|
+
|
335
|
+
Instead we will install version: ${chalk.green(needVersion)}
|
336
|
+
|
337
|
+
These versions may not work properly together.
|
338
|
+
`));
|
278
339
|
logger.log();
|
279
340
|
} // see if version supplied is a path to a binary
|
280
341
|
|
281
342
|
|
282
|
-
return fs.pathExistsAsync(needVersion).then(
|
343
|
+
return fs.pathExistsAsync(needVersion).then(exists => {
|
283
344
|
if (exists) {
|
284
345
|
return path.extname(needVersion) === '.zip' ? needVersion : false;
|
285
346
|
}
|
286
347
|
|
287
|
-
|
348
|
+
const possibleFile = util.formAbsolutePath(needVersion);
|
288
349
|
debug('checking local file', possibleFile, 'cwd', process.cwd());
|
289
|
-
return fs.pathExistsAsync(possibleFile).then(
|
350
|
+
return fs.pathExistsAsync(possibleFile).then(exists => {
|
290
351
|
// if this exists return the path to it
|
291
352
|
// else false
|
292
353
|
if (exists && path.extname(possibleFile) === '.zip') {
|
@@ -295,20 +356,20 @@ var start = function start() {
|
|
295
356
|
|
296
357
|
return false;
|
297
358
|
});
|
298
|
-
}).then(
|
359
|
+
}).then(pathToLocalFile => {
|
299
360
|
if (pathToLocalFile) {
|
300
|
-
|
361
|
+
const absolutePath = path.resolve(needVersion);
|
301
362
|
debug('found local file at', absolutePath);
|
302
363
|
debug('skipping download');
|
303
|
-
|
364
|
+
const rendererOptions = getRendererOptions();
|
304
365
|
return new Listr([unzipTask({
|
305
366
|
progress: {
|
306
367
|
throttle: 100,
|
307
368
|
onProgress: null
|
308
369
|
},
|
309
370
|
zipFilePath: absolutePath,
|
310
|
-
installDir
|
311
|
-
rendererOptions
|
371
|
+
installDir,
|
372
|
+
rendererOptions
|
312
373
|
})], rendererOptions).run();
|
313
374
|
}
|
314
375
|
|
@@ -318,50 +379,53 @@ var start = function start() {
|
|
318
379
|
}
|
319
380
|
|
320
381
|
debug('preparing to download and unzip version ', needVersion, 'to path', installDir);
|
321
|
-
|
382
|
+
const downloadDir = os.tmpdir();
|
322
383
|
return downloadAndUnzip({
|
323
384
|
version: needVersion,
|
324
|
-
installDir
|
325
|
-
downloadDir
|
385
|
+
installDir,
|
386
|
+
downloadDir
|
326
387
|
});
|
327
388
|
}) // delay 1 sec for UX, unless we are testing
|
328
|
-
.then(
|
389
|
+
.then(() => {
|
329
390
|
return Promise.delay(1000);
|
330
391
|
}).then(displayCompletionMsg);
|
331
392
|
});
|
332
393
|
};
|
333
394
|
|
334
395
|
module.exports = {
|
335
|
-
start
|
396
|
+
start,
|
397
|
+
_getVersionSpecifier: getVersionSpecifier,
|
398
|
+
_getBinaryUrlFromPrereleaseNpmUrl: getBinaryUrlFromPrereleaseNpmUrl
|
336
399
|
};
|
337
400
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
401
|
+
const unzipTask = ({
|
402
|
+
zipFilePath,
|
403
|
+
installDir,
|
404
|
+
progress,
|
405
|
+
rendererOptions
|
406
|
+
}) => {
|
343
407
|
return {
|
344
408
|
title: util.titleize('Unzipping Cypress'),
|
345
|
-
task:
|
409
|
+
task: (ctx, task) => {
|
346
410
|
// as our unzip progresses indicate the status
|
347
|
-
progress.onProgress = progessify(
|
411
|
+
progress.onProgress = progessify(task, 'Unzipping Cypress');
|
348
412
|
return unzip.start({
|
349
|
-
zipFilePath
|
350
|
-
installDir
|
351
|
-
progress
|
352
|
-
}).then(
|
353
|
-
util.setTaskTitle(
|
413
|
+
zipFilePath,
|
414
|
+
installDir,
|
415
|
+
progress
|
416
|
+
}).then(() => {
|
417
|
+
util.setTaskTitle(task, util.titleize(chalk.green('Unzipped Cypress')), rendererOptions.renderer);
|
354
418
|
});
|
355
419
|
}
|
356
420
|
};
|
357
421
|
};
|
358
422
|
|
359
|
-
|
423
|
+
const progessify = (task, title) => {
|
360
424
|
// return higher order function
|
361
|
-
return
|
362
|
-
percentComplete = chalk.white(
|
425
|
+
return (percentComplete, remaining) => {
|
426
|
+
percentComplete = chalk.white(` ${percentComplete}%`); // pluralize seconds remaining
|
363
427
|
|
364
|
-
remaining = chalk.gray(
|
428
|
+
remaining = chalk.gray(`${remaining}s`);
|
365
429
|
util.setTaskTitle(task, util.titleize(title, percentComplete, remaining), getRendererOptions().renderer);
|
366
430
|
};
|
367
431
|
}; // if we are running in CI then use
|
@@ -369,14 +433,14 @@ var progessify = function progessify(task, title) {
|
|
369
433
|
// the default
|
370
434
|
|
371
435
|
|
372
|
-
|
373
|
-
|
436
|
+
const getRendererOptions = () => {
|
437
|
+
let renderer = util.isCi() ? verbose : 'default';
|
374
438
|
|
375
439
|
if (logger.logLevel() === 'silent') {
|
376
440
|
renderer = 'silent';
|
377
441
|
}
|
378
442
|
|
379
443
|
return {
|
380
|
-
renderer
|
444
|
+
renderer
|
381
445
|
};
|
382
446
|
};
|