mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: stop using console.assert everywhere (#2646)
Since Node 10, `console.assert` no longer throws an AssertionError. (This is generally good since it aligns Node.js with Browsers.) This patch migrates all usages of `console.assert` in our codebase. - All the `lib/` and testing code is migrated onto a handmade `assert` function. This is to make Puppeteer transpilation / bundling easier. - All the tooling is switched to use Node's `assert` module. Fixes #2547.
This commit is contained in:
@@ -22,7 +22,7 @@ const {Connection} = require('./Connection');
|
||||
const {Browser} = require('./Browser');
|
||||
const readline = require('readline');
|
||||
const fs = require('fs');
|
||||
const {helper, debugError} = require('./helper');
|
||||
const {helper, assert, debugError} = require('./helper');
|
||||
const ChromiumRevision = require(path.join(helper.projectRoot(), 'package.json')).puppeteer.chromium_revision;
|
||||
|
||||
const mkdtempAsync = helper.promisify(fs.mkdtemp);
|
||||
@@ -60,7 +60,7 @@ class Launcher {
|
||||
*/
|
||||
static async launch(options) {
|
||||
options = Object.assign({}, options || {});
|
||||
console.assert(!options.ignoreDefaultArgs || !options.appMode, '`appMode` flag cannot be used together with `ignoreDefaultArgs`');
|
||||
assert(!options.ignoreDefaultArgs || !options.appMode, '`appMode` flag cannot be used together with `ignoreDefaultArgs`');
|
||||
let temporaryUserDataDir = null;
|
||||
const chromeArguments = [];
|
||||
if (!options.ignoreDefaultArgs)
|
||||
@@ -100,7 +100,7 @@ class Launcher {
|
||||
if (typeof chromeExecutable !== 'string') {
|
||||
const browserFetcher = new BrowserFetcher();
|
||||
const revisionInfo = browserFetcher.revisionInfo(ChromiumRevision);
|
||||
console.assert(revisionInfo.local, `Chromium revision is not downloaded. Run "npm install" or "yarn install"`);
|
||||
assert(revisionInfo.local, `Chromium revision is not downloaded. Run "npm install" or "yarn install"`);
|
||||
chromeExecutable = revisionInfo.executablePath;
|
||||
}
|
||||
if (Array.isArray(options.args))
|
||||
|
||||
Reference in New Issue
Block a user