From f4bd3e84c24c915a36968983a8dc50eb7718c795 Mon Sep 17 00:00:00 2001 From: Rick Brown Date: Tue, 4 Aug 2020 19:00:13 +1000 Subject: [PATCH] Caching the downloaded archive (#30) * Implement filesystem caching of downloaded binary Closes #24 * Fix failure to install multiple times on Mac * Cater for different OSs sharing node_modules Closes #25 * Update proposed filesystem caching after feedback * Turn caching on by default, using default filesystem locations * `CHROMIUM_CACHE` now overrides default cache location * Add flag `CHROMIUM_CACHE_SKIP` to disable caching * Many little refactors as suggested * Updated readme accordingly * Delete temporary files when the process exits * Refactor setEnvVar test util method * Ask wise and all-knowing friend for cache location * Rename CHROMIUM_CACHE to NODE_CHROMIUM_CACHE * Update readme * Rename cacheDir variable now cachedir is in scope dtolstyi would never let me get away with that :) * Rename all env vars CHROMIUM_* > NODE_CHROMIUM_* * More resilient progress bar and rename env var --- README.MD | 44 +++++++++++++----- cache.js | 57 ++++++++++++++++++++++++ index.js | 3 +- install.js | 65 +++++++++++++++++++-------- package-lock.json | 22 ++++----- package.json | 4 +- test/_utils.js | 64 ++++++++++++++++++++++++++ test/test-cache.js | 104 +++++++++++++++++++++++++++++++++++++++++++ test/test-config.js | 34 ++++++-------- test/test-install.js | 20 ++++----- test/test-utils.js | 4 +- utils.js | 4 +- 12 files changed, 342 insertions(+), 83 deletions(-) create mode 100644 cache.js create mode 100644 test/_utils.js create mode 100644 test/test-cache.js diff --git a/README.MD b/README.MD index f603e07..805a737 100644 --- a/README.MD +++ b/README.MD @@ -40,40 +40,40 @@ npm config set https-proxy http://:@:///.zip?alt=media` for example see the taobao mirror [chromium-browser-snapshots](https://npm.taobao.org/mirrors/chromium-browser-snapshots/). +* Mirrors are expected to host binaries in the structure: `///.zip?alt=media` for example see the taobao mirror [chromium-browser-snapshots](https://npm.taobao.org/mirrors/chromium-browser-snapshots/). * May also be set in .npmrc like so: ```ini -chromium_download_host=https://npm.taobao.org/mirrors/chromium-browser-snapshots/ -chromium_revision=737027 +node_chromium_download_host=https://npm.taobao.org/mirrors/chromium-browser-snapshots/ +node_chromium_revision=737027 ``` ## Selenium WebDriver Headless (without UI) tests @@ -121,7 +121,27 @@ async function takeScreenshot(driver, name) { start(); ``` -## + +### Cache Downloaded Binaries +By default downloaded chromium binaries are cached in the appropriate cache directory for your operating system. + +You may override the cache path by setting the `NODE_CHROMIUM_CACHE_PATH` environment variable to a directory path, for example: + +```bash +export NODE_CHROMIUM_CACHE_PATH=/path/to/cache/dir/ + +# or in .npmrc like so: +# node_chromium_cache_path=/path/to/cache/dir/ +``` + +You may disable caching by setting `NODE_CHROMIUM_CACHE_DISABLE` to `true`: + +```bash +export NODE_CHROMIUM_CACHE_DISABLE=true + +# or in .npmrc like so: +# node_chromium_cache_disable=true +``` ## License MIT diff --git a/cache.js b/cache.js new file mode 100644 index 0000000..e081501 --- /dev/null +++ b/cache.js @@ -0,0 +1,57 @@ +'use strict'; +const path = require('path'); +const fs = require('fs'); +const cachedir = require('cachedir'); +const config = require('./config'); + +/** + * Retrieve a Chromium archive from filesystem cache. + * @param {string} revision The Chromium revision to retrieve. + * @returns {string} The path to the cached Chromium archive. Falsy if not found. + */ +function get(revision) { + const cachePath = buildCachePath(revision); + if (fs.existsSync(cachePath)) { + return cachePath; + } + + return ''; +} + +/** + * Store a Chromium archive in filesystem cache for future use. + * Has no effect if the user has not configured a cache location. + * @param {string} revision The Chromium revision in the archive file. + * @param {string} filePath The path to the Chromium archive file to store in cache. + */ +function put(revision, filePath) { + const cachePath = buildCachePath(revision); + if (cachePath && filePath) { + try { + fs.mkdirSync(path.dirname(cachePath), {recursive: true}); + fs.copyFileSync(filePath, cachePath); + } catch (error) { + // Don't die on cache fail + console.error('Could not cache file', cachePath, error); + } + } +} + +/** + * Get the unique cache path for this revision, on this platform and architecture. + * @param {string} revision The revision of this Chromium binary, essentially a unique cache key. + * @returns {string} The cache path, or falsy if caching is not enabled. + */ +function buildCachePath(revision) { + if (!revision || config.getEnvVar('NODE_CHROMIUM_CACHE_DISABLE').toLowerCase() === 'true') { + return ''; + } + + const cachePath = config.getEnvVar('NODE_CHROMIUM_CACHE_PATH') || cachedir('node-chromium'); + return path.join(cachePath, `chromium-${revision}-${process.platform}-${process.arch}.zip`); +} + +module.exports = { + get, + put +}; diff --git a/index.js b/index.js index ccd100d..03709c2 100644 --- a/index.js +++ b/index.js @@ -15,5 +15,6 @@ function getBinaryPath() { } module.exports = { - path: getBinaryPath() + path: getBinaryPath(), + install: require('./install') }; diff --git a/install.js b/install.js index e3ca22b..44c8481 100644 --- a/install.js +++ b/install.js @@ -1,14 +1,17 @@ 'use strict'; +const path = require('path'); const fs = require('fs'); const extractZip = require('extract-zip'); const got = require('got'); const tmp = require('tmp'); const debug = require('debug')('node-chromium'); +const rimraf = require('rimraf'); const ProgressBar = require('progress'); const config = require('./config'); const utils = require('./utils'); +const cache = require('./cache'); let progressBar = null; @@ -27,13 +30,26 @@ function createTempFile() { }); } +/** + * Downloads the Chromium archive from the default CDN or mirror if configured. + * If the required archive is retrieved from the cache directory then the download will be skipped. + * @param {string} revision The Chromium revision to download. + */ async function downloadChromiumRevision(revision) { - const tmpPath = await createTempFile(); + const cacheEntry = cache.get(revision); + if (cacheEntry) { + debug('Found Chromium archive in cache, skipping download'); + + return Promise.resolve(cacheEntry); + } debug('Downloading Chromium archive from Google CDN'); const url = utils.getDownloadUrl(revision); - - return _downloadFile(url, tmpPath); + const tmpPath = await createTempFile(); + return _downloadFile(url, tmpPath).then(tmpPath => { + cache.put(revision, tmpPath); + return tmpPath; + }); } function _downloadFile(url, destPath) { @@ -60,6 +76,7 @@ function _downloadFile(url, destPath) { * @param progress Information about progress so far. */ function onProgress(progress) { + const fakeProgressBar = {tick: () => {}}; try { if (!progressBar) { const formatBytes = bytes => { @@ -67,17 +84,22 @@ function onProgress(progress) { return `${Math.round(mb * 10) / 10} MB`; }; - progressBar = new ProgressBar(`Downloading Chromium - ${formatBytes(progress.total)} [:bar] :percent :etas `, { - width: 20, - total: progress.total - }); + if (progress.total) { + progressBar = new ProgressBar(`Downloading Chromium - ${formatBytes(progress.total)} [:bar] :percent :etas `, { + width: 20, + total: progress.total + }); + } else { + progressBar = fakeProgressBar; + console.info('\tPlease wait, this may take a while...'); + } } progressBar.tick(progress.transferred - progressBar.curr); } catch (error) { // Don't die on progress bar failure, log it and stop progress console.error('Error displaying progress bar. Continuing anyway...', error); - progressBar = {tick: () => {}}; + progressBar = fakeProgressBar; } } @@ -85,29 +107,32 @@ function unzipArchive(archivePath, outputFolder) { debug('Started extracting archive', archivePath); return new Promise((resolve, reject) => { - extractZip(archivePath, {dir: outputFolder}, error => { - if (error) { - console.error('An error occurred while trying to extract archive', error); - reject(error); - } else { - debug('Archive was successfully extracted'); - resolve(true); - } + const osOutputFolder = path.join(outputFolder, utils.getOsChromiumFolderName()); + rimraf(osOutputFolder, () => { + extractZip(archivePath, {dir: outputFolder}, error => { + if (error) { + console.error('An error occurred while trying to extract archive', error); + reject(error); + } else { + debug('Archive was successfully extracted'); + resolve(true); + } + }); }); }); } async function install() { - const chromiumRevision = config.getEnvVar('CHROMIUM_REVISION'); + const chromiumRevision = config.getEnvVar('NODE_CHROMIUM_REVISION'); try { console.info('Step 1. Retrieving Chromium revision number'); const revision = chromiumRevision || await utils.getLatestRevisionNumber(); console.info(`Step 2. Downloading Chromium revision ${revision}`); - const tmpPath = await downloadChromiumRevision(revision); + const archivePath = await downloadChromiumRevision(revision); console.info('Step 3. Setting up Chromium binaries'); - await unzipArchive(tmpPath, config.BIN_OUT_PATH); + await unzipArchive(archivePath, config.BIN_OUT_PATH); console.info('Process is successfully finished'); } catch (error) { @@ -120,4 +145,6 @@ if (require.main === module) { install(); } +tmp.setGracefulCleanup(); // Ensure temporary files are cleaned up when process exits + module.exports = install; diff --git a/package-lock.json b/package-lock.json index 961940a..83e486d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -901,8 +901,7 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "base": { "version": "0.11.2", @@ -1067,7 +1066,6 @@ "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1318,6 +1316,11 @@ } } }, + "cachedir": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-2.3.0.tgz", + "integrity": "sha512-A+Fezp4zxnit6FanDmv9EqXNAi3vt9DWp51/71UEhXukb7QUuvtv9344h91dyAxuTLoSYJFU299qzR3tzwPAhw==" + }, "call-me-maybe": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", @@ -1552,8 +1555,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { "version": "1.6.2", @@ -3752,8 +3754,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { "version": "2.1.3", @@ -4326,7 +4327,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -5080,7 +5080,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5697,8 +5696,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-parse": { "version": "1.0.6", @@ -6227,7 +6225,6 @@ "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, "requires": { "glob": "^7.1.3" }, @@ -6236,7 +6233,6 @@ "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", diff --git a/package.json b/package.json index 704ccd9..1d16643 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "test-only": "ava --verbose" }, "files": [ + "cache.js", "config.js", "index.js", "install.js", @@ -34,16 +35,17 @@ "space": 4 }, "dependencies": { + "cachedir": "^2.3.0", "debug": "^4.1.0", "extract-zip": "^1.7.0", "got": "^11.5.1", "progress": "^2.0.3", + "rimraf": "^2.7.1", "tmp": "0.0.33", "tunnel": "^0.0.6" }, "devDependencies": { "ava": "^3.11.0", - "rimraf": "^2.7.1", "xo": "^0.32.1" } } diff --git a/test/_utils.js b/test/_utils.js new file mode 100644 index 0000000..b5ecbf3 --- /dev/null +++ b/test/_utils.js @@ -0,0 +1,64 @@ +/* +* Test utils +*/ +const platform = process.platform; +const arch = process.arch; + +/** + * Sets an environment variable and the corresponding npm_config variant. + * + * @param {string} name The UPPER_CASE name of the environment variable. + * @param {string} value The value to set - if falsy will be deleted. + */ +function setEnvVar(name, value) { + const npmName = `npm_config_${name.toLowerCase()}`; + process.env[name] = value; + process.env[npmName] = value; +} + +/** + * Clear an environment variable and the corresponding npm_config variant. + * + * @param {string} name The UPPER_CASE name of the environment variable. + */ +function clearEnvVar(name) { + const npmName = `npm_config_${name.toLowerCase()}`; + delete process.env[name]; + delete process.env[npmName]; +} + +/** + * Mocks out the platform value on the global process object. + * @param {string} newPlatformValue The mock platform. + */ +function mockPlatform(newPlatformValue) { + Object.defineProperty(process, 'platform', { + value: newPlatformValue + }); +} + +/** + * Mocks out the arch value on the global process object. + * @param {string} newArchValue The mock architecture. + */ +function mockArch(newArchValue) { + Object.defineProperty(process, 'arch', { + value: newArchValue + }); +} + +/** + * Resets all mocked properties. + */ +function clearMocks() { + mockPlatform(platform); + mockArch(arch); +} + +module.exports = { + mockPlatform, + mockArch, + clearMocks, + setEnvVar, + clearEnvVar +}; diff --git a/test/test-cache.js b/test/test-cache.js new file mode 100644 index 0000000..919cb58 --- /dev/null +++ b/test/test-cache.js @@ -0,0 +1,104 @@ +'use strict'; +const os = require('os'); +const fs = require('fs'); +const path = require('path'); +const test = require('ava'); +const testUtils = require('./_utils'); +const cache = require('../cache'); +let idx = 0; + +/* eslint camelcase: ["error", {properties: "never"}] */ + +test.beforeEach(t => { + setCacheDir(); + t.pass(); +}); + +test.afterEach(t => { + testUtils.clearMocks(); + t.pass(); +}); + +test.serial('get with null returns falsy', t => { + t.falsy(cache.get(null)); +}); + +test.serial('get with no hit returns falsy', t => { + t.falsy(cache.get('foobar')); +}); + +test.serial('put and retrieve cached file when disabled', t => { + process.env.NODE_CHROMIUM_CACHE_DISABLE = 'true'; + const revision = Date.now().toString(); + const file = createDummyFile(); + t.falsy(cache.get(revision), 'There should be no cached file before the test'); + cache.put(revision, file); + t.falsy(cache.get(revision), 'There should still be no cached file'); +}); + +test.serial('put and retrieve cached file', t => { + const revision = Date.now().toString(); + const file = createDummyFile(); + t.falsy(cache.get(revision), 'There should be no cached file at this point'); + cache.put(revision, file); + const fileContent = fs.readFileSync(file, 'utf8'); + const actualContent = fs.readFileSync(cache.get(revision), 'utf8'); + t.is(fileContent, actualContent, 'The cached file should match the source file'); +}); + +test.serial('put and overwrite existing cached file', t => { + const revision = Date.now().toString(); + const file = createDummyFile(); + t.falsy(cache.get(revision), 'There should be no cached file at this point'); + cache.put(revision, file); + t.truthy(cache.get(revision), 'There should be a cached file at this point'); + cache.put(revision, file); // Nothing bad should happen +}); + +test.serial('cache entries for different platforms do not collide', t => { + const revision = Date.now().toString(); + ['darwin', 'linux', 'windows'].forEach(platform => { + testUtils.mockPlatform(platform); + const file = createDummyFile(); + t.falsy(cache.get(revision), 'There should be no cached file at this point'); + cache.put(revision, file); + const fileContent = fs.readFileSync(file, 'utf8'); + const actualContent = fs.readFileSync(cache.get(revision), 'utf8'); + t.is(fileContent, actualContent, 'The cached file should match the source file'); + }); +}); + +test.serial('cache entries for different architectures do not collide', t => { + const revision = Date.now().toString(); + ['x32', 'x64'].forEach(arch => { + testUtils.mockArch(arch); + const file = createDummyFile(); + t.falsy(cache.get(revision), 'There should be no cached file at this point'); + cache.put(revision, file); + const fileContent = fs.readFileSync(file, 'utf8'); + const actualContent = fs.readFileSync(cache.get(revision), 'utf8'); + t.is(fileContent, actualContent, 'The cached file should match the source file'); + }); +}); + +/** + * Configures node-chromium to use a filesystem cache. + */ +function setCacheDir() { + const cacheDir = path.join(os.tmpdir(), 'chromium-cache'); + fs.mkdirSync(cacheDir, {recursive: true}); + testUtils.setEnvVar('NODE_CHROMIUM_CACHE_PATH', cacheDir); + testUtils.clearEnvVar('NODE_CHROMIUM_CACHE_DISABLE'); +} + +/** + * Creates a text file which, for the purposes of the cache test, can be treated as a chromium binary, + */ +function createDummyFile() { + const temporaryDir = os.tmpdir(); + const uid = `${Date.now()}_${idx++}`; + const name = `${uid}.txt`; + const filePath = path.join(temporaryDir, name); + fs.writeFileSync(filePath, `Hello ${uid}`); + return filePath; +} diff --git a/test/test-config.js b/test/test-config.js index de3226d..7db327f 100644 --- a/test/test-config.js +++ b/test/test-config.js @@ -2,43 +2,35 @@ const test = require('ava'); +const testUtils = require('./_utils'); const config = require('../config'); /* eslint camelcase: ["error", {properties: "never"}] */ +test.beforeEach(t => { + testUtils.clearEnvVar('FOO_BAR'); + t.pass(); +}); + test.serial('getEnvVar returns string always', t => { - delete process.env.FOO_BAR; // Make sure this doesn't exist t.is('', config.getEnvVar('FOO_BAR')); }); test.serial('getEnvVar basic test', t => { const expected = Date.now().toString(); - try { - process.env.FOO_BAR = expected; - t.is(expected, config.getEnvVar('FOO_BAR')); - } finally { - delete process.env.FOO_BAR; - } + process.env.FOO_BAR = expected; + t.is(expected, config.getEnvVar('FOO_BAR')); }); test.serial('getEnvVar looks for npm_config version', t => { const expected = Date.now().toString(); - try { - process.env.npm_config_foo_bar = expected; - t.is(expected, config.getEnvVar('FOO_BAR')); - } finally { - delete process.env.npm_config_foo_bar; - } + process.env.npm_config_foo_bar = expected; + t.is(expected, config.getEnvVar('FOO_BAR')); }); test.serial('getEnvVar prefers npm_config version', t => { const expected = Date.now().toString(); - try { - process.env.FOO_BAR = 'foobar'; - process.env.npm_config_foo_bar = expected; - t.is(expected, config.getEnvVar('FOO_BAR'), 'npm_config_ variant should trump raw env var'); - } finally { - delete process.env.FOO_BAR; - delete process.env.npm_config_foo_bar; - } + process.env.FOO_BAR = 'foobar'; + process.env.npm_config_foo_bar = expected; + t.is(expected, config.getEnvVar('FOO_BAR'), 'npm_config_ variant should trump raw env var'); }); diff --git a/test/test-install.js b/test/test-install.js index fe98dc3..e0efce2 100644 --- a/test/test-install.js +++ b/test/test-install.js @@ -7,6 +7,7 @@ const rimraf = require('rimraf'); const got = require('got'); const debug = require('debug')('node-chromium'); +const testUtils = require('./_utils'); const utils = require('../utils'); const config = require('../config'); const install = require('../install'); @@ -23,6 +24,11 @@ test.before(t => { t.pass(); }); +test.afterEach(t => { + testUtils.clearMocks(); + t.pass(); +}); + test.serial('Canary Test', t => { t.pass(); }); @@ -43,11 +49,9 @@ test.serial('Different OS support', async t => { const supportedPlatforms = ['darwin', 'linux', 'win32']; const notSupportedPlatforms = ['aix', 'freebsd', 'openbsd', 'sunos']; - const originalPlatform = process.platform; - /* eslint-disable no-await-in-loop */ for (const platform of supportedPlatforms) { - mockPlatform(platform); + testUtils.mockPlatform(platform); const revision = await utils.getLatestRevisionNumber(); @@ -57,15 +61,13 @@ test.serial('Different OS support', async t => { /* eslint-enable no-await-in-loop */ for (const platform of notSupportedPlatforms) { - mockPlatform(platform); + testUtils.mockPlatform(platform); t.throws(() => { utils.getDownloadUrl(); }, {message: 'Unsupported platform'}); } - mockPlatform(originalPlatform); - t.pass(); }); @@ -78,9 +80,3 @@ async function isUrlAccessible(url) { return false; } } - -function mockPlatform(newPlatformValue) { - Object.defineProperty(process, 'platform', { - value: newPlatformValue - }); -} diff --git a/test/test-utils.js b/test/test-utils.js index 5d2f6b0..13edf30 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -26,14 +26,14 @@ test.serial('getDownloadUrl contains revision', t => { }); test.serial('getDownloadUrl honors environment variable', t => { - process.env.CHROMIUM_DOWNLOAD_HOST = OVERRIDE_URL; + process.env.NODE_CHROMIUM_DOWNLOAD_HOST = OVERRIDE_URL; const url = utils.getDownloadUrl('737027'); t.true(url.indexOf(OVERRIDE_URL) === 0, `Download URL should honor environment variable ${OVERRIDE_URL} but got ${url}`); }); test.serial('getDownloadUrl honors npm config', t => { - process.env.npm_config_chromium_download_host = OVERRIDE_URL; + process.env.npm_config_node_chromium_download_host = OVERRIDE_URL; const url = utils.getDownloadUrl('737027'); t.true(url.indexOf(OVERRIDE_URL) === 0, `Download URL should honor npm config ${OVERRIDE_URL} but got ${url}`); diff --git a/utils.js b/utils.js index af5b217..b06c8b0 100644 --- a/utils.js +++ b/utils.js @@ -57,7 +57,7 @@ module.exports = { * @returns {string} */ getDownloadUrl(revision) { - const altUrl = config.getEnvVar('CHROMIUM_DOWNLOAD_HOST'); + const altUrl = config.getEnvVar('NODE_CHROMIUM_DOWNLOAD_HOST'); let revisionPath = `/${revision}/${this.getOsChromiumFolderName()}`; if (!altUrl) { revisionPath = encodeURIComponent(revisionPath); // Needed for googleapis.com @@ -72,7 +72,7 @@ module.exports = { * @returns {string} */ getOsCdnUrl() { - let url = config.getEnvVar('CHROMIUM_DOWNLOAD_HOST') || config.CDN_URL; + let url = config.getEnvVar('NODE_CHROMIUM_DOWNLOAD_HOST') || config.CDN_URL; const platform = process.platform;