fix: stop setting npm_config_ env vars from config during lifecycle scripts#55
Merged
Conversation
…cripts pnpm-specific config settings (allowbuilds, shared-workspace-lockfile, resolution-mode, patches-dir, catalog, etc.) were being exported as npm_config_* environment variables during lifecycle scripts. This caused npm to warn about unknown config when scripts invoked npm internally. Like Yarn, only set the well-known npm_* env vars that the ecosystem depends on (npm_lifecycle_event, npm_execpath, npm_package_*, etc.) and stop dumping the entire config object as npm_config_* vars.
There was a problem hiding this comment.
Pull request overview
This PR updates the lifecycle environment construction to avoid exporting pnpm-specific configuration as npm_config_* environment variables during lifecycle scripts, preventing npm warnings when scripts invoke npm internally.
Changes:
- Removed logic that exported the entire
opts.configobject intonpm_config_*andnpm_package_config_*env vars. - Updated
makeEnvtests to assert that config-derived env vars are no longer set. - Cleaned up unused imports related to the removed config-export logic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
index.js |
Stops exporting opts.config into npm_config_* / config override env vars; removes now-unused imports. |
test/index.js |
Adjusts expectations to ensure config is not surfaced via npm_config_* / pnpm_config_* and config overrides are not set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
7
to
14
| const { execute } = require('@yarnpkg/shell') | ||
| const { npath } = require('@yarnpkg/fslib') | ||
| const path = require('path') | ||
| const Stream = require('stream').Stream | ||
| const fs = require('fs') | ||
| const chain = require('slide').chain | ||
| const uidNumber = require('uid-number') | ||
| const umask = require('umask') | ||
| const byline = require('@pnpm/byline') | ||
| const { PnpmError } = require('@pnpm/error') |
There was a problem hiding this comment.
umask is no longer required/used in this module, but it is still listed as a runtime dependency in package.json. Please remove it from dependencies (or reintroduce the usage) to avoid shipping an unused dependency.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pnpm-specific config settings (allowbuilds, shared-workspace-lockfile, resolution-mode, patches-dir, catalog, etc.) were being exported as npm_config_* environment variables during lifecycle scripts. This caused npm to warn about unknown config when scripts invoked npm internally.
Like Yarn, only set the well-known npm_* env vars that the ecosystem depends on (npm_lifecycle_event, npm_execpath, npm_package_, etc.) and stop dumping the entire config object as npm_config_ vars.