cypress 4.4.1 → 4.5.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 +15 -6
- package/lib/cli.js +56 -53
- package/lib/cypress.js +8 -9
- package/lib/errors.js +216 -84
- package/lib/exec/info.js +17 -13
- package/lib/exec/open.js +4 -1
- package/lib/exec/run.js +20 -24
- package/lib/exec/spawn.js +56 -53
- package/lib/exec/versions.js +9 -6
- package/lib/exec/xvfb.js +29 -27
- package/lib/fs.js +1 -1
- package/lib/logger.js +16 -12
- package/lib/tasks/cache.js +11 -12
- package/lib/tasks/download.js +100 -73
- package/lib/tasks/install.js +125 -73
- package/lib/tasks/state.js +35 -19
- package/lib/tasks/unzip.js +38 -44
- package/lib/tasks/verify.js +101 -64
- package/lib/util.js +112 -107
- package/package.json +1 -1
package/lib/tasks/unzip.js
CHANGED
@@ -1,14 +1,23 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
var _ = require('lodash');
|
4
|
+
|
4
5
|
var la = require('lazy-ass');
|
6
|
+
|
5
7
|
var is = require('check-more-types');
|
8
|
+
|
6
9
|
var cp = require('child_process');
|
10
|
+
|
7
11
|
var os = require('os');
|
12
|
+
|
8
13
|
var yauzl = require('yauzl');
|
14
|
+
|
9
15
|
var debug = require('debug')('cypress:cli:unzip');
|
16
|
+
|
10
17
|
var extract = require('extract-zip');
|
18
|
+
|
11
19
|
var Promise = require('bluebird');
|
20
|
+
|
12
21
|
var readline = require('readline');
|
13
22
|
|
14
23
|
var _require = require('../errors'),
|
@@ -16,17 +25,17 @@ var _require = require('../errors'),
|
|
16
25
|
errors = _require.errors;
|
17
26
|
|
18
27
|
var fs = require('../fs');
|
28
|
+
|
19
29
|
var util = require('../util');
|
20
30
|
|
21
31
|
var unzipTools = {
|
22
32
|
extract: extract
|
33
|
+
}; // expose this function for simple testing
|
23
34
|
|
24
|
-
|
25
|
-
};var unzip = function unzip(_ref) {
|
35
|
+
var unzip = function unzip(_ref) {
|
26
36
|
var zipFilePath = _ref.zipFilePath,
|
27
37
|
installDir = _ref.installDir,
|
28
38
|
progress = _ref.progress;
|
29
|
-
|
30
39
|
debug('unzipping from %s', zipFilePath);
|
31
40
|
debug('into', installDir);
|
32
41
|
|
@@ -36,7 +45,6 @@ var unzipTools = {
|
|
36
45
|
|
37
46
|
var startTime = Date.now();
|
38
47
|
var yauzlDoneTime = 0;
|
39
|
-
|
40
48
|
return fs.ensureDirAsync(installDir).then(function () {
|
41
49
|
return new Promise(function (resolve, reject) {
|
42
50
|
return yauzl.open(zipFilePath, function (err, zipFile) {
|
@@ -44,33 +52,25 @@ var unzipTools = {
|
|
44
52
|
|
45
53
|
if (err) {
|
46
54
|
debug('error using yauzl %s', err.message);
|
47
|
-
|
48
55
|
return reject(err);
|
49
56
|
}
|
50
57
|
|
51
58
|
var total = zipFile.entryCount;
|
52
|
-
|
53
59
|
debug('zipFile entries count', total);
|
54
|
-
|
55
60
|
var started = new Date();
|
56
|
-
|
57
61
|
var percent = 0;
|
58
62
|
var count = 0;
|
59
63
|
|
60
64
|
var notify = function notify(percent) {
|
61
65
|
var elapsed = +new Date() - +started;
|
62
|
-
|
63
66
|
var eta = util.calculateEta(percent, elapsed);
|
64
|
-
|
65
67
|
progress.onProgress(percent, util.secsRemaining(eta));
|
66
68
|
};
|
67
69
|
|
68
70
|
var tick = function tick() {
|
69
71
|
count += 1;
|
70
|
-
|
71
72
|
percent = count / total * 100;
|
72
73
|
var displayPercent = percent.toFixed(0);
|
73
|
-
|
74
74
|
return notify(displayPercent);
|
75
75
|
};
|
76
76
|
|
@@ -80,12 +80,10 @@ var unzipTools = {
|
|
80
80
|
var endFn = function endFn(err) {
|
81
81
|
if (err) {
|
82
82
|
debug('error %s', err.message);
|
83
|
-
|
84
83
|
return reject(err);
|
85
84
|
}
|
86
85
|
|
87
86
|
debug('node unzip finished');
|
88
|
-
|
89
87
|
return resolve();
|
90
88
|
};
|
91
89
|
|
@@ -93,9 +91,7 @@ var unzipTools = {
|
|
93
91
|
dir: installDir,
|
94
92
|
onEntry: tick
|
95
93
|
};
|
96
|
-
|
97
94
|
debug('calling Node extract tool %s %o', zipFilePath, opts);
|
98
|
-
|
99
95
|
return unzipTools.extract(zipFilePath, opts, endFn);
|
100
96
|
};
|
101
97
|
|
@@ -103,74 +99,64 @@ var unzipTools = {
|
|
103
99
|
|
104
100
|
var unzipWithUnzipTool = function unzipWithUnzipTool() {
|
105
101
|
debug('unzipping via `unzip`');
|
106
|
-
|
107
102
|
var inflatingRe = /inflating:/;
|
108
|
-
|
109
103
|
var sp = cp.spawn('unzip', ['-o', zipFilePath, '-d', installDir]);
|
110
|
-
|
111
104
|
sp.on('error', function (err) {
|
112
105
|
debug('unzip tool error: %s', err.message);
|
113
106
|
unzipFallback();
|
114
107
|
});
|
115
|
-
|
116
108
|
sp.on('close', function (code) {
|
117
109
|
debug('unzip tool close with code %d', code);
|
110
|
+
|
118
111
|
if (code === 0) {
|
119
112
|
percent = 100;
|
120
113
|
notify(percent);
|
121
|
-
|
122
114
|
return resolve();
|
123
115
|
}
|
124
116
|
|
125
|
-
debug('`unzip` failed %o', {
|
126
|
-
|
117
|
+
debug('`unzip` failed %o', {
|
118
|
+
code: code
|
119
|
+
});
|
127
120
|
return unzipFallback();
|
128
121
|
});
|
129
|
-
|
130
122
|
sp.stdout.on('data', function (data) {
|
131
123
|
if (inflatingRe.test(data)) {
|
132
124
|
return tick();
|
133
125
|
}
|
134
126
|
});
|
135
|
-
|
136
127
|
sp.stderr.on('data', function (data) {
|
137
128
|
debug('`unzip` stderr %s', data);
|
138
129
|
});
|
139
|
-
};
|
140
|
-
|
141
|
-
// we attempt to first unzip with the native osx
|
130
|
+
}; // we attempt to first unzip with the native osx
|
142
131
|
// ditto because its less likely to have problems
|
143
132
|
// with corruption, symlinks, or icons causing failures
|
144
133
|
// and can handle resource forks
|
145
134
|
// http://automatica.com.au/2011/02/unzip-mac-os-x-zip-in-terminal/
|
135
|
+
|
136
|
+
|
146
137
|
var unzipWithOsx = function unzipWithOsx() {
|
147
138
|
debug('unzipping via `ditto`');
|
148
|
-
|
149
139
|
var copyingFileRe = /^copying file/;
|
140
|
+
var sp = cp.spawn('ditto', ['-xkV', zipFilePath, installDir]); // f-it just unzip with node
|
150
141
|
|
151
|
-
var sp = cp.spawn('ditto', ['-xkV', zipFilePath, installDir]);
|
152
|
-
|
153
|
-
// f-it just unzip with node
|
154
142
|
sp.on('error', function (err) {
|
155
143
|
debug(err.message);
|
156
144
|
unzipFallback();
|
157
145
|
});
|
158
|
-
|
159
146
|
sp.on('close', function (code) {
|
160
147
|
if (code === 0) {
|
161
148
|
// make sure we get to 100% on the progress bar
|
162
149
|
// because reading in lines is not really accurate
|
163
150
|
percent = 100;
|
164
151
|
notify(percent);
|
165
|
-
|
166
152
|
return resolve();
|
167
153
|
}
|
168
154
|
|
169
|
-
debug('`ditto` failed %o', {
|
170
|
-
|
155
|
+
debug('`ditto` failed %o', {
|
156
|
+
code: code
|
157
|
+
});
|
171
158
|
return unzipFallback();
|
172
159
|
});
|
173
|
-
|
174
160
|
return readline.createInterface({
|
175
161
|
input: sp.stderr
|
176
162
|
}).on('line', function (line) {
|
@@ -183,10 +169,13 @@ var unzipTools = {
|
|
183
169
|
switch (os.platform()) {
|
184
170
|
case 'darwin':
|
185
171
|
return unzipWithOsx();
|
172
|
+
|
186
173
|
case 'linux':
|
187
174
|
return unzipWithUnzipTool();
|
175
|
+
|
188
176
|
case 'win32':
|
189
177
|
return unzipWithNode();
|
178
|
+
|
190
179
|
default:
|
191
180
|
return;
|
192
181
|
}
|
@@ -204,23 +193,28 @@ var start = function start(_ref2) {
|
|
204
193
|
var zipFilePath = _ref2.zipFilePath,
|
205
194
|
installDir = _ref2.installDir,
|
206
195
|
progress = _ref2.progress;
|
207
|
-
|
208
196
|
la(is.unemptyString(installDir), 'missing installDir');
|
197
|
+
|
209
198
|
if (!progress) {
|
210
|
-
progress = {
|
199
|
+
progress = {
|
200
|
+
onProgress: function onProgress() {
|
211
201
|
return {};
|
212
|
-
}
|
202
|
+
}
|
203
|
+
};
|
213
204
|
}
|
214
205
|
|
215
206
|
return fs.pathExists(installDir).then(function (exists) {
|
216
207
|
if (exists) {
|
217
208
|
debug('removing existing unzipped binary', installDir);
|
218
|
-
|
219
209
|
return fs.removeAsync(installDir);
|
220
210
|
}
|
221
211
|
}).then(function () {
|
222
|
-
return unzip({
|
223
|
-
|
212
|
+
return unzip({
|
213
|
+
zipFilePath: zipFilePath,
|
214
|
+
installDir: installDir,
|
215
|
+
progress: progress
|
216
|
+
});
|
217
|
+
})["catch"](throwFormErrorText(errors.failedUnzip));
|
224
218
|
};
|
225
219
|
|
226
220
|
module.exports = {
|
package/lib/tasks/verify.js
CHANGED
@@ -1,25 +1,76 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
_templateObject3 = _taggedTemplateLiteral(['\n ', ' You have set the environment variable:\n\n ', '', '\n\n This overrides the default Cypress binary path used.\n '], ['\n ', ' You have set the environment variable:\n\n ', '', '\n\n This overrides the default Cypress binary path used.\n ']),
|
6
|
-
_templateObject4 = _taggedTemplateLiteral(['\n The supplied binary path is not executable\n '], ['\n The supplied binary path is not executable\n ']),
|
7
|
-
_templateObject5 = _taggedTemplateLiteral(['\n\n\n ', ' Warning: Binary version ', ' does not match the expected package version ', '\n\n These versions may not work properly together.\n '], ['\n\n\n ', ' Warning: Binary version ', ' does not match the expected package version ', '\n\n These versions may not work properly together.\n ']);
|
3
|
+
function _templateObject5() {
|
4
|
+
var data = _taggedTemplateLiteral(["\n\n\n ", " Warning: Binary version ", " does not match the expected package version ", "\n\n These versions may not work properly together.\n "]);
|
8
5
|
|
9
|
-
function
|
6
|
+
_templateObject5 = function _templateObject5() {
|
7
|
+
return data;
|
8
|
+
};
|
9
|
+
|
10
|
+
return data;
|
11
|
+
}
|
12
|
+
|
13
|
+
function _templateObject4() {
|
14
|
+
var data = _taggedTemplateLiteral(["\n The supplied binary path is not executable\n "]);
|
15
|
+
|
16
|
+
_templateObject4 = function _templateObject4() {
|
17
|
+
return data;
|
18
|
+
};
|
19
|
+
|
20
|
+
return data;
|
21
|
+
}
|
22
|
+
|
23
|
+
function _templateObject3() {
|
24
|
+
var data = _taggedTemplateLiteral(["\n ", " You have set the environment variable:\n\n ", "", "\n\n This overrides the default Cypress binary path used.\n "]);
|
25
|
+
|
26
|
+
_templateObject3 = function _templateObject3() {
|
27
|
+
return data;
|
28
|
+
};
|
29
|
+
|
30
|
+
return data;
|
31
|
+
}
|
32
|
+
|
33
|
+
function _templateObject2() {
|
34
|
+
var data = _taggedTemplateLiteral(["\n It looks like this is your first time using Cypress: ", "\n "]);
|
35
|
+
|
36
|
+
_templateObject2 = function _templateObject2() {
|
37
|
+
return data;
|
38
|
+
};
|
39
|
+
|
40
|
+
return data;
|
41
|
+
}
|
42
|
+
|
43
|
+
function _templateObject() {
|
44
|
+
var data = _taggedTemplateLiteral(["\n Cypress executable not found at: ", "\n "]);
|
45
|
+
|
46
|
+
_templateObject = function _templateObject() {
|
47
|
+
return data;
|
48
|
+
};
|
49
|
+
|
50
|
+
return data;
|
51
|
+
}
|
52
|
+
|
53
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
10
54
|
|
11
55
|
var _ = require('lodash');
|
56
|
+
|
12
57
|
var chalk = require('chalk');
|
58
|
+
|
13
59
|
var Listr = require('listr');
|
60
|
+
|
14
61
|
var debug = require('debug')('cypress:cli');
|
62
|
+
|
15
63
|
var verbose = require('@cypress/listr-verbose-renderer');
|
16
64
|
|
17
65
|
var _require = require('common-tags'),
|
18
66
|
stripIndent = _require.stripIndent;
|
19
67
|
|
20
68
|
var Promise = require('bluebird');
|
69
|
+
|
21
70
|
var logSymbols = require('log-symbols');
|
71
|
+
|
22
72
|
var path = require('path');
|
73
|
+
|
23
74
|
var os = require('os');
|
24
75
|
|
25
76
|
var _require2 = require('../errors'),
|
@@ -27,28 +78,32 @@ var _require2 = require('../errors'),
|
|
27
78
|
errors = _require2.errors;
|
28
79
|
|
29
80
|
var util = require('../util');
|
81
|
+
|
30
82
|
var logger = require('../logger');
|
83
|
+
|
31
84
|
var xvfb = require('../exec/xvfb');
|
85
|
+
|
32
86
|
var state = require('./state');
|
33
87
|
|
34
88
|
var VERIFY_TEST_RUNNER_TIMEOUT_MS = 30000;
|
35
89
|
|
36
90
|
var checkExecutable = function checkExecutable(binaryDir) {
|
37
91
|
var executable = state.getPathToExecutable(binaryDir);
|
38
|
-
|
39
92
|
debug('checking if executable exists', executable);
|
40
|
-
|
41
93
|
return util.isExecutableAsync(executable).then(function (isExecutable) {
|
42
94
|
debug('Binary is executable? :', isExecutable);
|
95
|
+
|
43
96
|
if (!isExecutable) {
|
44
97
|
return throwFormErrorText(errors.binaryNotExecutable(executable))();
|
45
98
|
}
|
46
|
-
})
|
99
|
+
})["catch"]({
|
100
|
+
code: 'ENOENT'
|
101
|
+
}, function () {
|
47
102
|
if (util.isCi()) {
|
48
103
|
return throwFormErrorText(errors.notInstalledCI(executable))();
|
49
104
|
}
|
50
105
|
|
51
|
-
return throwFormErrorText(errors.missingApp(binaryDir))(stripIndent(_templateObject, chalk.cyan(executable)));
|
106
|
+
return throwFormErrorText(errors.missingApp(binaryDir))(stripIndent(_templateObject(), chalk.cyan(executable)));
|
52
107
|
});
|
53
108
|
};
|
54
109
|
|
@@ -58,20 +113,16 @@ var runSmokeTest = function runSmokeTest(binaryDir, options) {
|
|
58
113
|
var onSmokeTestError = function onSmokeTestError(smokeTestCommand, linuxWithDisplayEnv) {
|
59
114
|
return function (err) {
|
60
115
|
debug('Smoke test failed:', err);
|
61
|
-
|
62
116
|
var errMessage = err.stderr || err.message;
|
63
|
-
|
64
117
|
debug('error message:', errMessage);
|
65
118
|
|
66
119
|
if (err.timedOut) {
|
67
120
|
debug('error timedOut is true');
|
68
|
-
|
69
121
|
return throwFormErrorText(errors.smokeTestFailure(smokeTestCommand, true))(errMessage);
|
70
122
|
}
|
71
123
|
|
72
124
|
if (linuxWithDisplayEnv && util.isBrokenGtkDisplay(errMessage)) {
|
73
125
|
util.logBrokenGtkDisplayWarning();
|
74
|
-
|
75
126
|
return throwFormErrorText(errors.invalidSmokeTestDisplayError)(errMessage);
|
76
127
|
}
|
77
128
|
|
@@ -80,16 +131,16 @@ var runSmokeTest = function runSmokeTest(binaryDir, options) {
|
|
80
131
|
};
|
81
132
|
|
82
133
|
var needsXvfb = xvfb.isNeeded();
|
83
|
-
|
84
134
|
debug('needs Xvfb?', needsXvfb);
|
85
|
-
|
86
135
|
/**
|
87
136
|
* Spawn Cypress running smoke test to check if all operating system
|
88
137
|
* dependencies are good.
|
89
138
|
*/
|
139
|
+
|
90
140
|
var spawn = function spawn(linuxWithDisplayEnv) {
|
91
141
|
var random = _.random(0, 1000);
|
92
|
-
|
142
|
+
|
143
|
+
var args = ['--smoke-test', "--ping=".concat(random)];
|
93
144
|
|
94
145
|
if (needsSandbox()) {
|
95
146
|
// electron requires --no-sandbox to run as root
|
@@ -102,8 +153,7 @@ var runSmokeTest = function runSmokeTest(binaryDir, options) {
|
|
102
153
|
args.unshift(path.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'));
|
103
154
|
}
|
104
155
|
|
105
|
-
var smokeTestCommand = executable
|
106
|
-
|
156
|
+
var smokeTestCommand = "".concat(executable, " ").concat(args.join(' '));
|
107
157
|
debug('running smoke test');
|
108
158
|
debug('using Cypress executable %s', executable);
|
109
159
|
debug('smoke test command:', smokeTestCommand);
|
@@ -118,7 +168,7 @@ var runSmokeTest = function runSmokeTest(binaryDir, options) {
|
|
118
168
|
timeout: options.smokeTestTimeout
|
119
169
|
});
|
120
170
|
|
121
|
-
return Promise.resolve(util.exec(executable, args, stdioOptions))
|
171
|
+
return Promise.resolve(util.exec(executable, args, stdioOptions))["catch"](onSmokeTestError(smokeTestCommand, linuxWithDisplayEnv)).then(function (result) {
|
122
172
|
// TODO: when execa > 1.1 is released
|
123
173
|
// change this to `result.all` for both stderr and stdout
|
124
174
|
// use lodash to be robust during tests against null result or missing stdout
|
@@ -130,8 +180,8 @@ var runSmokeTest = function runSmokeTest(binaryDir, options) {
|
|
130
180
|
debug('Smoke test failed because could not find %d in:', random, result);
|
131
181
|
|
132
182
|
var smokeTestStderr = _.get(result, 'stderr', '');
|
133
|
-
var errorText = smokeTestStderr || smokeTestStdout;
|
134
183
|
|
184
|
+
var errorText = smokeTestStderr || smokeTestStdout;
|
135
185
|
return throwFormErrorText(errors.smokeTestFailure(smokeTestCommand, false))(errorText);
|
136
186
|
}
|
137
187
|
});
|
@@ -140,78 +190,68 @@ var runSmokeTest = function runSmokeTest(binaryDir, options) {
|
|
140
190
|
var spawnInXvfb = function spawnInXvfb(linuxWithDisplayEnv) {
|
141
191
|
return xvfb.start().then(function () {
|
142
192
|
return spawn(linuxWithDisplayEnv);
|
143
|
-
})
|
193
|
+
})["finally"](xvfb.stop);
|
144
194
|
};
|
145
195
|
|
146
196
|
var userFriendlySpawn = function userFriendlySpawn(linuxWithDisplayEnv) {
|
147
197
|
debug('spawning, should retry on display problem?', Boolean(linuxWithDisplayEnv));
|
148
|
-
|
149
|
-
|
198
|
+
return spawn(linuxWithDisplayEnv)["catch"]({
|
199
|
+
code: 'INVALID_SMOKE_TEST_DISPLAY_ERROR'
|
200
|
+
}, function () {
|
150
201
|
return spawnInXvfb(linuxWithDisplayEnv);
|
151
202
|
});
|
152
203
|
};
|
153
204
|
|
154
205
|
if (needsXvfb) {
|
155
206
|
return spawnInXvfb();
|
156
|
-
}
|
157
|
-
|
158
|
-
// if we are on linux and there's already a DISPLAY
|
207
|
+
} // if we are on linux and there's already a DISPLAY
|
159
208
|
// set, then we may need to rerun cypress after
|
160
209
|
// spawning our own Xvfb server
|
161
|
-
var linuxWithDisplayEnv = util.isPossibleLinuxWithIncorrectDisplay();
|
162
210
|
|
211
|
+
|
212
|
+
var linuxWithDisplayEnv = util.isPossibleLinuxWithIncorrectDisplay();
|
163
213
|
return userFriendlySpawn(linuxWithDisplayEnv);
|
164
214
|
};
|
165
215
|
|
166
216
|
function testBinary(version, binaryDir, options) {
|
167
|
-
debug('running binary verification check', version);
|
217
|
+
debug('running binary verification check', version); // if running from 'cypress verify', don't print this message
|
168
218
|
|
169
|
-
// if running from 'cypress verify', don't print this message
|
170
219
|
if (!options.force) {
|
171
|
-
logger.log(stripIndent(_templateObject2, chalk.cyan(version)));
|
220
|
+
logger.log(stripIndent(_templateObject2(), chalk.cyan(version)));
|
172
221
|
}
|
173
222
|
|
174
|
-
logger.log();
|
175
|
-
|
176
|
-
// if we are running in CI then use
|
223
|
+
logger.log(); // if we are running in CI then use
|
177
224
|
// the verbose renderer else use
|
178
225
|
// the default
|
179
|
-
var renderer = util.isCi() ? verbose : 'default';
|
180
226
|
|
227
|
+
var renderer = util.isCi() ? verbose : 'default';
|
181
228
|
if (logger.logLevel() === 'silent') renderer = 'silent';
|
182
|
-
|
183
229
|
var rendererOptions = {
|
184
230
|
renderer: renderer
|
185
231
|
};
|
186
|
-
|
187
232
|
var tasks = new Listr([{
|
188
233
|
title: util.titleize('Verifying Cypress can run', chalk.gray(binaryDir)),
|
189
234
|
task: function task(ctx, _task) {
|
190
235
|
debug('clearing out the verified version');
|
191
|
-
|
192
236
|
return state.clearBinaryStateAsync(binaryDir).then(function () {
|
193
|
-
return Promise.all([runSmokeTest(binaryDir, options), Promise.resolve().delay(1500)
|
194
|
-
);
|
237
|
+
return Promise.all([runSmokeTest(binaryDir, options), Promise.resolve().delay(1500) // good user experience
|
238
|
+
]);
|
195
239
|
}).then(function () {
|
196
240
|
debug('write verified: true');
|
197
|
-
|
198
241
|
return state.writeBinaryVerifiedAsync(true, binaryDir);
|
199
242
|
}).then(function () {
|
200
243
|
util.setTaskTitle(_task, util.titleize(chalk.green('Verified Cypress!'), chalk.gray(binaryDir)), rendererOptions.renderer);
|
201
244
|
});
|
202
245
|
}
|
203
246
|
}], rendererOptions);
|
204
|
-
|
205
247
|
return tasks.run();
|
206
248
|
}
|
207
249
|
|
208
250
|
var maybeVerify = function maybeVerify(installedVersion, binaryDir, options) {
|
209
251
|
return state.getBinaryVerifiedAsync(binaryDir).then(function (isVerified) {
|
210
252
|
debug('is Verified ?', isVerified);
|
253
|
+
var shouldVerify = !isVerified; // force verify if options.force
|
211
254
|
|
212
|
-
var shouldVerify = !isVerified;
|
213
|
-
|
214
|
-
// force verify if options.force
|
215
255
|
if (options.force) {
|
216
256
|
debug('force verify');
|
217
257
|
shouldVerify = true;
|
@@ -230,9 +270,7 @@ var maybeVerify = function maybeVerify(installedVersion, binaryDir, options) {
|
|
230
270
|
|
231
271
|
var start = function start() {
|
232
272
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
233
|
-
|
234
273
|
debug('verifying Cypress app');
|
235
|
-
|
236
274
|
var packageVersion = util.pkgVersion();
|
237
275
|
var binaryDir = state.getBinaryDir(packageVersion);
|
238
276
|
|
@@ -249,16 +287,14 @@ var start = function start() {
|
|
249
287
|
|
250
288
|
var parseBinaryEnvVar = function parseBinaryEnvVar() {
|
251
289
|
var envBinaryPath = util.getEnv('CYPRESS_RUN_BINARY');
|
252
|
-
|
253
290
|
debug('CYPRESS_RUN_BINARY exists, =', envBinaryPath);
|
254
|
-
logger.log(stripIndent(_templateObject3, chalk.yellow('Note:'), chalk.white('CYPRESS_RUN_BINARY='), chalk.cyan(envBinaryPath)));
|
255
|
-
|
291
|
+
logger.log(stripIndent(_templateObject3(), chalk.yellow('Note:'), chalk.white('CYPRESS_RUN_BINARY='), chalk.cyan(envBinaryPath)));
|
256
292
|
logger.log();
|
257
|
-
|
258
293
|
return util.isExecutableAsync(envBinaryPath).then(function (isExecutable) {
|
259
294
|
debug('CYPRESS_RUN_BINARY is executable? :', isExecutable);
|
295
|
+
|
260
296
|
if (!isExecutable) {
|
261
|
-
return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(stripIndent(_templateObject4));
|
297
|
+
return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(stripIndent(_templateObject4()));
|
262
298
|
}
|
263
299
|
}).then(function () {
|
264
300
|
return state.parseRealPlatformBinaryFolderAsync(envBinaryPath);
|
@@ -268,15 +304,17 @@ var start = function start() {
|
|
268
304
|
}
|
269
305
|
|
270
306
|
debug('CYPRESS_RUN_BINARY has binaryDir:', envBinaryDir);
|
271
|
-
|
272
307
|
binaryDir = envBinaryDir;
|
273
|
-
})
|
308
|
+
})["catch"]({
|
309
|
+
code: 'ENOENT'
|
310
|
+
}, function (err) {
|
274
311
|
return throwFormErrorText(errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(err.message);
|
275
312
|
});
|
276
313
|
};
|
277
314
|
|
278
|
-
return Promise
|
315
|
+
return Promise["try"](function () {
|
279
316
|
debug('checking environment variables');
|
317
|
+
|
280
318
|
if (util.getEnv('CYPRESS_RUN_BINARY')) {
|
281
319
|
return parseBinaryEnvVar();
|
282
320
|
}
|
@@ -289,24 +327,22 @@ var start = function start() {
|
|
289
327
|
}).then(function (binaryVersion) {
|
290
328
|
if (!binaryVersion) {
|
291
329
|
debug('no Cypress binary found for cli version ', packageVersion);
|
292
|
-
|
293
|
-
return throwFormErrorText(errors.missingApp(binaryDir))('\n Cannot read binary version from: ' + chalk.cyan(state.getBinaryPkgPath(binaryDir)) + '\n ');
|
330
|
+
return throwFormErrorText(errors.missingApp(binaryDir))("\n Cannot read binary version from: ".concat(chalk.cyan(state.getBinaryPkgPath(binaryDir)), "\n "));
|
294
331
|
}
|
295
332
|
|
296
|
-
debug(
|
333
|
+
debug("Found binary version ".concat(chalk.green(binaryVersion), " installed in: ").concat(chalk.cyan(binaryDir)));
|
297
334
|
|
298
335
|
if (binaryVersion !== packageVersion) {
|
299
336
|
// warn if we installed with CYPRESS_INSTALL_BINARY or changed version
|
300
337
|
// in the package.json
|
301
|
-
logger.log(
|
338
|
+
logger.log("Found binary version ".concat(chalk.green(binaryVersion), " installed in: ").concat(chalk.cyan(binaryDir)));
|
302
339
|
logger.log();
|
303
|
-
logger.warn(stripIndent(_templateObject5, logSymbols.warning, chalk.green(binaryVersion), chalk.green(packageVersion)));
|
304
|
-
|
340
|
+
logger.warn(stripIndent(_templateObject5(), logSymbols.warning, chalk.green(binaryVersion), chalk.green(packageVersion)));
|
305
341
|
logger.log();
|
306
342
|
}
|
307
343
|
|
308
344
|
return maybeVerify(binaryVersion, binaryDir, options);
|
309
|
-
})
|
345
|
+
})["catch"](function (err) {
|
310
346
|
if (err.known) {
|
311
347
|
throw err;
|
312
348
|
}
|
@@ -318,7 +354,6 @@ var start = function start() {
|
|
318
354
|
var isLinuxLike = function isLinuxLike() {
|
319
355
|
return os.platform() !== 'win32';
|
320
356
|
};
|
321
|
-
|
322
357
|
/**
|
323
358
|
* Returns true if running on a system where Electron needs "--no-sandbox" flag.
|
324
359
|
* @see https://crbug.com/638180
|
@@ -328,6 +363,8 @@ var isLinuxLike = function isLinuxLike() {
|
|
328
363
|
* Seems there is a lot of discussion around this issue among Electron users
|
329
364
|
* @see https://github.com/electron/electron/issues/17972
|
330
365
|
*/
|
366
|
+
|
367
|
+
|
331
368
|
var needsSandbox = function needsSandbox() {
|
332
369
|
return isLinuxLike();
|
333
370
|
};
|