fix: Allow PUPPETEER_EXECUTABLE_PATH to be set in npmrc and package.json (#4270)

This PR sets fixes the PUPPETEER_EXECUTABLE_PATH environment variable so that it can be set in the .npmrc or package.json like the documentation says.

The npm environment is initialized if puppeteer script is run from-inside `npm run` command.
This commit is contained in:
Travis Weidenbenner 2019-04-11 13:45:00 -05:00 committed by Andrey Lushnikov
parent 08e9a4ddaa
commit a79b775430

View File

@ -298,7 +298,7 @@ class Launcher {
const browserFetcher = new BrowserFetcher(this._projectRoot);
// puppeteer-core doesn't take into account PUPPETEER_* env variables.
if (!this._isPuppeteerCore) {
const executablePath = process.env['PUPPETEER_EXECUTABLE_PATH'];
const executablePath = process.env.PUPPETEER_EXECUTABLE_PATH || process.env.npm_config_puppeteer_executable_path || process.env.npm_package_config_puppeteer_executable_path;
if (executablePath) {
const missingText = !fs.existsSync(executablePath) ? 'Tried to use PUPPETEER_EXECUTABLE_PATH env variable to launch browser but did not find any executable at: ' + executablePath : null;
return { executablePath, missingText };