Skip to content

fix: propagate npmrcpath to lockfile shell targets#8407

Merged
olblak merged 6 commits into
updatecli:mainfrom
nickzerjeski:fix-npm-autodiscovery-npmrc-shell-7670
Apr 17, 2026
Merged

fix: propagate npmrcpath to lockfile shell targets#8407
olblak merged 6 commits into
updatecli:mainfrom
nickzerjeski:fix-npm-autodiscovery-npmrc-shell-7670

Conversation

@nickzerjeski

Copy link
Copy Markdown
Contributor

Fix #7670

Propagate npmrcpath to generated shell targets for lockfile updates by adding NPM_CONFIG_USERCONFIG to target environments when npmrcpath is configured.

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/autodiscovery/npm
go test -run 'TestNew_WithResourceConfig|TestDiscoverManifests_WithResourceConfig'

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

  • The environment variable is injected in shell targets only when npmrcpath is set, so manifests without npmrcpath are unchanged.

Potential improvement

  • Extend the test matrix with a hermetic pnpm/yarn command mock so full TestDiscoverManifests can assert all lockfile target variants without local tool dependencies.

Copilot AI review requested due to automatic review settings April 13, 2026 08:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Propagates a configured npmrcpath into generated lockfile-update shell targets by injecting NPM_CONFIG_USERCONFIG, ensuring npm/yarn/pnpm commands use the intended user config.

Changes:

  • Add conditional NPM_CONFIG_USERCONFIG environment variable to shell targets when .SourceNpmrcPath is set
  • Extend autodiscovery tests to assert the manifest includes the new environment variable

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pkg/plugins/autodiscovery/npm/manifestTemplate.go Injects NPM_CONFIG_USERCONFIG into generated shell target environments (npm/yarn/pnpm blocks) when npmrcpath is configured
pkg/plugins/autodiscovery/npm/main_test.go Adds assertions verifying the generated manifest includes NPM_CONFIG_USERCONFIG and the configured path

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/plugins/autodiscovery/npm/manifestTemplate.go Outdated
Comment thread pkg/plugins/autodiscovery/npm/main_test.go
Comment thread pkg/plugins/autodiscovery/npm/manifestTemplate.go Outdated
@nickzerjeski

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

@olblak

olblak commented Apr 14, 2026

Copy link
Copy Markdown
Member

Thank you for the pullrequest.
I'll try to find some time to review it

Comment thread pkg/plugins/autodiscovery/npm/manifestTemplate.go Outdated
Comment thread pkg/plugins/autodiscovery/npm/manifestTemplate.go Outdated
Comment thread pkg/plugins/autodiscovery/npm/manifestTemplate.go Outdated
loispostula
loispostula previously approved these changes Apr 14, 2026

@loispostula loispostula left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few formatting nit, otherwise looks good! Thanks

@olblak olblak enabled auto-merge (squash) April 17, 2026 06:53
@olblak olblak added bug Something isn't working resource-npm labels Apr 17, 2026
@olblak olblak merged commit e9215c5 into updatecli:main Apr 17, 2026
7 checks passed
@nickzerjeski nickzerjeski deleted the fix-npm-autodiscovery-npmrc-shell-7670 branch April 23, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working resource-npm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm autodiscovery: propagate npmrcpath to shell targets for lock file updates

4 participants