Skip to content

Commit 88f05df

Browse files
committed
fix!: reduce the amount of npm_package_ env variables
ref pnpm/pnpm#8552
1 parent 1e0f149 commit 88f05df

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,12 @@ function makeEnv (data, opts, prefix, env) {
370370
for (const i in data) {
371371
if (i.charAt(0) !== '_') {
372372
const envKey = (prefix + i).replace(/[^a-zA-Z0-9_]/g, '_')
373-
if (i === 'readme') {
373+
if (
374+
!['name', 'version', 'config', 'engines', 'bin'].includes(i) &&
375+
!prefix.startsWith('npm_package_config_') &&
376+
!prefix.startsWith('npm_package_engines_') &&
377+
!prefix.startsWith('npm_package_bin_')
378+
) {
374379
continue
375380
}
376381
if (data[i] && typeof data[i] === 'object') {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pnpm/npm-lifecycle",
3-
"version": "3.0.4",
3+
"version": "1000.0.0",
44
"description": "JavaScript package lifecycle hook runner",
55
"main": "index.js",
66
"scripts": {

test/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ test('makeEnv', function (t) {
142142
}, null, process.env)
143143

144144
t.equal('myPackage', env.npm_package_name, 'package data is included')
145-
t.equal('Mike Sherov', env.npm_package_contributors_0_name, 'nested package data is included')
146145

147146
t.equal('Infinity', env.npm_config_enteente, 'public config is included')
148147
t.equal(undefined, env.npm_config_privateVar, 'private config is excluded')

0 commit comments

Comments
 (0)