chore: improve error reporting when browse download fails (#4787)

This commit is contained in:
Yury Semikhatsky 2020-12-21 12:31:01 -08:00 committed by GitHub
parent 94ee48f8ce
commit 7bbda4370d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -27,6 +27,9 @@ try {
console.log(`Downloading browsers...`); console.log(`Downloading browsers...`);
const { installBrowsersWithProgressBar } = require('./lib/install/installer'); const { installBrowsersWithProgressBar } = require('./lib/install/installer');
installBrowsersWithProgressBar(__dirname); installBrowsersWithProgressBar(__dirname).catch(e => {
console.error(`Failed to install browsers, caused by\n${e.stack}`);
process.exit(1);
});
console.log(`Done. Use "npm run watch" to compile.`); console.log(`Done. Use "npm run watch" to compile.`);

View file

@ -103,7 +103,9 @@ async function validateCache(packagePath: string, browsersPath: string, linksDir
// 3. Install missing browsers for this package. // 3. Install missing browsers for this package.
const myBrowsersToDownload = await readBrowsersToDownload(packagePath); const myBrowsersToDownload = await readBrowsersToDownload(packagePath);
for (const browser of myBrowsersToDownload) { for (const browser of myBrowsersToDownload) {
await browserFetcher.downloadBrowserWithProgressBar(browsersPath, browser); await browserFetcher.downloadBrowserWithProgressBar(browsersPath, browser).catch(e => {
throw new Error(`Failed to download ${browser.name}, caused by\n${e.stack}`);
});
await fsWriteFileAsync(browserPaths.markerFilePath(browsersPath, browser), ''); await fsWriteFileAsync(browserPaths.markerFilePath(browsersPath, browser), '');
} }
} }