Skip to content

fix: forward env option to package manager for all operations - #280

Merged
pi0 merged 3 commits into
mainfrom
fix/forward-env
Oct 26, 2026
Merged

pi0 merged 3 commits into
mainfrom
fix/forward-env

Conversation

@pi0x

@pi0x pi0x commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

OperationOptions.env is part of the public API and is resolved by resolveOperationOptions. Until now, only runScript and dlx passed it to executeCommand. installDependencies, addDependency (also used by addDevDependency and ensureDependencyInstalled), removeDependency and dedupeDependencies silently ignored it.

This matters for nitrojs/nitro#4919. Nitro installs a dependency on demand during a build that runs with NODE_ENV=production and passes env: { NODE_ENV: "development" } so npm doesn't omit dev dependencies. Because nypm dropped that option, it had no effect.

Changes:

  • Forward env: resolvedOptions.env in all four missing executeCommand calls
  • Accept env in the narrowed option types of installDependencies, dedupeDependencies and ensureDependencyInstalled, and document it in the JSDoc
  • Add test/env.test.ts, which mocks tinyexec and checks that env reaches the child process for every operation, including ensureDependencyInstalled and dedupeDependencies with recreateLockfile (which reinstalls through installDependencies)

🤖 Generated with AI assistant

Summary by CodeRabbit

  • New Features
    • Dependency installation, addition, removal, checks, deduplication, script execution, and dlx commands now use the environment settings provided for the operation.
  • Documentation
    • API documentation now describes the environment option for dependency operations.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 472242ea-a3da-4223-bbf9-238daf522a20
Commits

Reviewing files that changed from the base of the PR and between 11d7f46 and 7929521.

Files selected for processing: 2
  • src/api.ts
  • test/env.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

Dependency operations now accept or document an environment option and pass the resolved environment to command execution. Tests check that package-manager operations pass NODE_ENV to command options.

Changes: Dependency operation environment

Layer / File(s) Summary
Environment options and command propagation
src/api.ts, test/env.test.ts
The API documents the environment option for dependency operations. installDependencies, ensureDependencyInstalled, and dedupeDependencies accept env. Package-manager commands pass the resolved environment to executeCommand. Tests check environment forwarding for the listed operations.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: pi0

Merge Risk: Minimal · up to 79295

The change is mergeable; environment options are forwarded for the supported package-manager operations.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: forwarding the env option to the package manager across operations.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pi0
pi0 merged commit e15eb59 into main Oct 26, 2026
4 of 5 checks passed
@pi0
pi0 deleted the fix/forward-env branch October 26, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants