forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(builtin): add environment attribute to yarn_install & npm_install
This allows you to specify a dict of environment variables for Bazel to set before calling yarn and npm in the yarn_install and npm_install repository rules respectively. Also set BAZEL_YARN_INSTALL to "1" and BAZEL_NPM_INSTALL to "1" respectively (unless they are set to another value by the environment attribute).
- Loading branch information
1 parent
5c36bd7
commit 56c31b3
Showing
6 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// This script is called by postinstall steps of yarn_install & npm_install rules in the root | ||
// WORKSPACE. It tests that the environment attribute sets environment variables as expected. | ||
|
||
const expectedYarn = 'yarn is great!'; | ||
if (process.env['BAZEL_YARN_INSTALL'] === '1' && process.env['SOME_USER_ENV'] !== expectedYarn) { | ||
throw `Expected SOME_USER_ENV environment variable to be set to '${ | ||
expectedYarn}' by yarn_install but got '${process.env['SOME_USER_ENV']}'`; | ||
} | ||
|
||
const expectedNpm = 'npm is cool!'; | ||
if (process.env['BAZEL_NPM_INSTALL'] === '1' && process.env['SOME_USER_ENV'] !== expectedNpm) { | ||
throw `Expected SOME_USER_ENV environment variable to be set to '${ | ||
expectedNpm}' by npm_install but got '${process.env['SOME_USER_ENV']}'`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters