Fail gracefully when chromium failed to download (#430)

Fail gracefully when chromium failed to download

This patch changes both install.js and Launcher.js to inform how
chromium could be downloaded manually.
This commit is contained in:
Andrey Lushnikov
2017-08-21 13:34:10 -07:00
committed by GitHub
parent 598f439a32
commit c1731dd5d7
4 changed files with 20 additions and 9 deletions

View File

@@ -15,18 +15,28 @@
*/
const Downloader = require('./utils/ChromiumDownloader');
const platform = Downloader.currentPlatform();
const revision = require('./package').puppeteer.chromium_revision;
const ProgressBar = require('progress');
const revisionInfo = Downloader.revisionInfo(platform, revision);
// Do nothing if the revision is already downloaded.
if (Downloader.revisionInfo(Downloader.currentPlatform(), revision))
if (revisionInfo.downloaded)
return;
let allRevisions = Downloader.downloadedRevisions();
Downloader.downloadRevision(Downloader.currentPlatform(), revision, onProgress)
Downloader.downloadRevision(platform, revision, onProgress)
// Remove previous chromium revisions.
.then(() => Promise.all(allRevisions.map(({platform, revision}) => Downloader.removeRevision(platform, revision))))
.catch(error => console.error('Download failed: ' + error.message));
.catch(onError);
function onError(error) {
console.error(`ERROR: Failed to download chromium r${revision}!
- Download chromium manually:
${revisionInfo.url}
- Extract chromium into ${revisionInfo.folderPath}
* Chromium executable should be at ${revisionInfo.executablePath}`);
}
let progressBar = null;
function onProgress(bytesTotal, delta) {