From 2babcb00212d2ec0102b4f2e3316d1138fd4a186 Mon Sep 17 00:00:00 2001 From: gordomium Date: Tue, 26 Sep 2017 10:10:46 +0800 Subject: [PATCH] [feat] Support PUPPETEER_SKIP_CHROMIUM_DOWNLOAD in npmrc This patch adds support for PUPPETEER_SKIP_CHROMIUM_DOWNLOAD variable in npm config. This aligns the variable with the rest of supported environment variables. --- docs/api.md | 2 +- install.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 18a6c3c0..0d761ab7 100644 --- a/docs/api.md +++ b/docs/api.md @@ -151,7 +151,7 @@ Puppeteer is a Node library which provides a high-level API to control Chromium Puppeteer looks for certain [environment variables](https://en.wikipedia.org/wiki/Environment_variable) to aid its operations: - `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. +- `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` - do not download bundled Chromium during installation step. (`puppeteer_skip_chromium_download` in `.npmrc` as same) ### class: Puppeteer Puppeteer module provides a method to launch a Chromium instance. diff --git a/install.js b/install.js index f7cb6c17..488897b4 100644 --- a/install.js +++ b/install.js @@ -18,6 +18,10 @@ if (process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD) { console.log('**INFO** Skipping Chromium download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" environment variable was found.'); return; } +if (process.env.NPM_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD || process.env.npm_config_puppeteer_skip_chromium_download) { + console.log('**INFO** Skipping Chromium download. "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" was set in npm config.'); + return; +} const Downloader = require('./utils/ChromiumDownloader'); const platform = Downloader.currentPlatform();