Skip to content

Commit

Permalink
fix!: reduce the amount of npm_package_ env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Dec 11, 2024
1 parent 1e0f149 commit 88f05df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ function makeEnv (data, opts, prefix, env) {
for (const i in data) {
if (i.charAt(0) !== '_') {
const envKey = (prefix + i).replace(/[^a-zA-Z0-9_]/g, '_')
if (i === 'readme') {
if (
!['name', 'version', 'config', 'engines', 'bin'].includes(i) &&
!prefix.startsWith('npm_package_config_') &&
!prefix.startsWith('npm_package_engines_') &&
!prefix.startsWith('npm_package_bin_')
) {
continue
}
if (data[i] && typeof data[i] === 'object') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pnpm/npm-lifecycle",
"version": "3.0.4",
"version": "1000.0.0",
"description": "JavaScript package lifecycle hook runner",
"main": "index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ test('makeEnv', function (t) {
}, null, process.env)

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

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

0 comments on commit 88f05df

Please sign in to comment.