Skip to content

Commit

Permalink
fixup: cleaner packageEnvs
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jan 22, 2024
1 parent 073018b commit a907044
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lib/package-envs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const packageEnvs = (env, vals, prefix) => {
for (const [key, val] of Object.entries(vals)) {
if (val === undefined) {
Expand All @@ -19,10 +18,12 @@ const packageEnvs = (env, vals, prefix) => {
}

// https://github.com/npm/rfcs/pull/183 defines which fields we put into the environment
module.exports = (env, pkg) => packageEnvs({ ...env }, {
name: pkg.name,
version: pkg.version,
config: pkg.config,
engines: pkg.engines,
bin: pkg.bin,
}, 'npm_package_')
module.exports = pkg => {
return packageEnvs({}, {
name: pkg.name,
version: pkg.version,
config: pkg.config,
engines: pkg.engines,
bin: pkg.bin,
}, 'npm_package_')
}
2 changes: 1 addition & 1 deletion lib/run-script-pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const runScriptPkg = async options => {
path,
scriptShell,
binPaths,
env: packageEnvs(env, pkg),
env: { ...env, ...packageEnvs(pkg) },
stdio,
cmd,
args,
Expand Down

0 comments on commit a907044

Please sign in to comment.