@percy/core
Advanced tools
Comparing version 1.0.0-beta.36 to 1.0.0-beta.37
@@ -14,3 +14,3 @@ "use strict"; | ||
var _child_process = require("child_process"); | ||
var _crossSpawn = _interopRequireDefault(require("cross-spawn")); | ||
@@ -25,3 +25,3 @@ var _events = _interopRequireDefault(require("events")); | ||
var _installBrowser = _interopRequireDefault(require("../utils/install-browser")); | ||
var _install = _interopRequireDefault(require("../install")); | ||
@@ -79,3 +79,3 @@ var _page = _interopRequireDefault(require("./page")); | ||
this.executable = executable || (await (0, _installBrowser.default)()); // create a temporary profile directory | ||
this.executable = executable || (await _install.default.chromium()); // create a temporary profile directory | ||
@@ -92,4 +92,4 @@ this.profile = await _fs.promises.mkdtemp(_path.default.join(_os.default.tmpdir(), 'percy-browser-')); // collect args to pass to the browser process | ||
this.process = (0, _child_process.spawn)(this.executable, args, { | ||
detached: true | ||
this.process = (0, _crossSpawn.default)(this.executable, args, { | ||
detached: process.platform !== 'win32' | ||
}); // connect a websocket to the devtools address | ||
@@ -140,18 +140,14 @@ | ||
this.pages.clear(); // no executable means the browser never launched | ||
this.pages.clear(); // resolves when the browser has closed | ||
/* istanbul ignore next: sanity */ | ||
if (!this.executable) return; // attempt to close the browser gracefully | ||
let closed = new Promise(resolve => { | ||
this.process.on('exit', resolve); | ||
}); | ||
/* istanbul ignore next: | ||
* difficult to test failure here without mocking private properties */ | ||
/* istanbul ignore next: race condition paranoia */ | ||
if (!this.process || this.process.exitCode) resolve();else this.process.on('exit', resolve); | ||
}); // force close if needed and able to | ||
await this.send('Browser.close').catch(() => { | ||
let kill = () => { | ||
var _this$process; | ||
// force close if needed and able to | ||
/* istanbul ignore next: | ||
* difficult to test failure here without mocking private properties */ | ||
if ((_this$process = this.process) !== null && _this$process !== void 0 && _this$process.pid && !this.process.killed) { | ||
@@ -164,15 +160,32 @@ try { | ||
} | ||
}); // attempt to clean up the profile directory after closing | ||
}; | ||
/* istanbul ignore else: | ||
* difficult to test failure here without mocking private properties */ | ||
if (this.profile) kill();else this.send('Browser.close').catch(() => kill()); // after closing, attempt to clean up the profile directory | ||
await closed.then(() => new Promise(resolve => { | ||
(0, _rimraf.default)(this.profile, error => { | ||
/* istanbul ignore next: | ||
* this might happen on some systems but ultimately it is a temp file */ | ||
if (error) { | ||
this.log.debug('Could not clean up temporary browser profile directory.'); | ||
this.log.debug(error); | ||
} | ||
var _this$process2, _this$process3, _this$process4; | ||
// needed due to a bug in Node 12 - https://github.com/nodejs/node/issues/27097 | ||
(_this$process2 = this.process) === null || _this$process2 === void 0 ? void 0 : _this$process2.stdin.end(); | ||
(_this$process3 = this.process) === null || _this$process3 === void 0 ? void 0 : _this$process3.stdout.end(); | ||
(_this$process4 = this.process) === null || _this$process4 === void 0 ? void 0 : _this$process4.stderr.end(); | ||
/* istanbul ignore else: sanity */ | ||
if (this.profile) { | ||
(0, _rimraf.default)(this.profile, error => { | ||
/* istanbul ignore next: | ||
* this might happen on some systems but ultimately it is a temp file */ | ||
if (error) { | ||
this.log.debug('Could not clean up temporary browser profile directory.'); | ||
this.log.debug(error); | ||
} | ||
resolve(); | ||
}); | ||
} else { | ||
resolve(); | ||
}); | ||
} | ||
})); | ||
@@ -202,2 +215,4 @@ } | ||
async send(method, params) { | ||
/* istanbul ignore next: | ||
* difficult to test failure here without mocking private properties */ | ||
if (!this.isConnected()) throw new Error('Browser not connected'); // every command needs a unique id | ||
@@ -254,3 +269,3 @@ | ||
return reject(new Error(`Failed to launch browser. ${(_error$message = error === null || error === void 0 ? void 0 : error.message) !== null && _error$message !== void 0 ? _error$message : ''}` + '\n', stderr, '\n\n')); | ||
return reject(new Error(`Failed to launch browser. ${(_error$message = error === null || error === void 0 ? void 0 : error.message) !== null && _error$message !== void 0 ? _error$message : ''}\n${stderr}'\n\n`)); | ||
}); | ||
@@ -257,0 +272,0 @@ }; |
{ | ||
"name": "@percy/core", | ||
"version": "1.0.0-beta.36", | ||
"version": "1.0.0-beta.37", | ||
"license": "MIT", | ||
@@ -16,6 +16,6 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "babel --root-mode upward src --out-dir dist", | ||
"build": "cross-env NODE_ENV=production babel src --out-dir dist --root-mode upward", | ||
"lint": "eslint --ignore-path ../../.gitignore .", | ||
"pretest": "node ../../scripts/install-browser", | ||
"test": "cross-env NODE_ENV=test mocha --recursive", | ||
"postinstall": "node ./post-install", | ||
"test": "cross-env NODE_ENV=test mocha", | ||
"test:coverage": "nyc yarn test", | ||
@@ -29,9 +29,11 @@ "test:types": "tsd" | ||
"require": "../../scripts/babel-register", | ||
"recursive": true, | ||
"timeout": 10000 | ||
}, | ||
"dependencies": { | ||
"@percy/client": "^1.0.0-beta.36", | ||
"@percy/config": "^1.0.0-beta.36", | ||
"@percy/dom": "^1.0.0-beta.36", | ||
"@percy/logger": "^1.0.0-beta.36", | ||
"@percy/client": "^1.0.0-beta.37", | ||
"@percy/config": "^1.0.0-beta.37", | ||
"@percy/dom": "^1.0.0-beta.37", | ||
"@percy/logger": "^1.0.0-beta.37", | ||
"cross-spawn": "^7.0.3", | ||
"extract-zip": "^2.0.1", | ||
@@ -42,3 +44,3 @@ "progress": "^2.0.3", | ||
}, | ||
"gitHead": "b50360d0afa6e3b4c6c6bf7f5ef25d39031ca370" | ||
"gitHead": "49828f18be37eba7b6bfb0d45214a9937f8299fe" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
93390
2058
5
9
1
+ Addedcross-spawn@^7.0.3
+ Addedcross-spawn@7.0.5(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
Updated@percy/client@^1.0.0-beta.37
Updated@percy/config@^1.0.0-beta.37
Updated@percy/dom@^1.0.0-beta.37
Updated@percy/logger@^1.0.0-beta.37