Skip to content

Commit e489659

Browse files
committed
feat: opt.extraEnv
ref pnpm/pnpm#2528
1 parent 40f3554 commit e489659

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jump in if you'd like to, or even ask us questions if something isn't clear.
4343
* `opts.stdio` - the [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio)
4444
passed to the child process. `[0, 1, 2]` by default.
4545
* `opts.runConcurrently` - *Boolean* - `false` by default. If `true`, lifecycle scripts may run concurrently.
46+
* `opts.extraEnv` - *Record<string, string>* - add some extra env vars to the exec environment of the lifecycle script.
4647

4748
##### Example
4849

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ function lifecycle (pkg, stage, wd, opts) {
8282
env.npm_execpath = require.main.filename
8383
env.INIT_CWD = process.cwd()
8484
env.npm_config_node_gyp = env.npm_config_node_gyp || DEFAULT_NODE_GYP_PATH
85+
if (opts.extraEnv) {
86+
for (const [key, value] of Object.entries(opts.extraEnv)) {
87+
env[key] = value
88+
}
89+
}
8590

8691
// 'nobody' typically doesn't have permission to write to /tmp
8792
// even if it's never used, sh freaks out.

0 commit comments

Comments
 (0)