From 8b0fd0ae4ac955fb19d71bddcaffb5dba7ce97a3 Mon Sep 17 00:00:00 2001 From: Andrey Rublev Date: Fri, 30 Mar 2018 19:49:48 +0200 Subject: [PATCH] feat(install): support npm config for chromium revision (#2290) This patch: - adds `npm_config_puppeteer_chromium_revision` support - clarifies api documentation about variables from npm config --- docs/api.md | 3 ++- install.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 75804c20f41..c27bba1078d 100644 --- a/docs/api.md +++ b/docs/api.md @@ -266,7 +266,8 @@ The Puppeteer API is hierarchical and mirrors the browser structure. On the foll ### Environment Variables -Puppeteer looks for certain [environment variables](https://en.wikipedia.org/wiki/Environment_variable) to aid its operations. These variables can either be set in the environment or in the [npm config](https://docs.npmjs.com/cli/config). +Puppeteer looks for certain [environment variables](https://en.wikipedia.org/wiki/Environment_variable) to aid its operations. +If puppeteer doesn't find them in environment, lowercased variant of these variables will be used from the [npm config](https://docs.npmjs.com/cli/config). - `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY` - defines HTTP proxy settings that are used to download and run Chromium. - `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` - do not download bundled Chromium during installation step. diff --git a/install.js b/install.js index 44f753103db..a4da083fdc0 100644 --- a/install.js +++ b/install.js @@ -30,7 +30,9 @@ const downloadHost = process.env.PUPPETEER_DOWNLOAD_HOST || process.env.npm_conf const puppeteer = require('./index'); const browserFetcher = puppeteer.createBrowserFetcher({ host: downloadHost }); -const revision = process.env.PUPPETEER_CHROMIUM_REVISION || require('./package.json').puppeteer.chromium_revision; +const revision = process.env.PUPPETEER_CHROMIUM_REVISION || process.env.npm_config_puppeteer_chromium_revision + || require('./package.json').puppeteer.chromium_revision; + const revisionInfo = browserFetcher.revisionInfo(revision); // Do nothing if the revision is already downloaded.