Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ steps = [
{ argv = ["vp", "dlx", "--help"], comment = "should show help message", continue-on-failure = true },
{ argv = ["vp", "dlx", "-s", "vp-test-echo", "hello"], comment = "should run vp-test-echo with npm exec", continue-on-failure = true },
{ argv = ["vp", "dlx", "-s", "vp-test-echo@1.0.0", "hello"], comment = "should run specific version", continue-on-failure = true },
{ argv = ["vp", "dlx", "-s", "vp-test-echo@1.0.0", "hello"], envs = [["npm_config_package", "vp-test-upper"]], comment = "should ignore `npm_config_package` from an outer `npx --package`", continue-on-failure = true },
{ argv = ["vp", "dlx", "-s", "@vp-test/cli@npm:vp-test-echo@1.0.0", "hello"], comment = "npm selects the binary rather than using the scoped alias name" },
{ argv = ["vp", "dlx", "-s", "-p", "vp-test-echo", "-p", "vp-test-upper", "vp-test-echo", "hello"], comment = "should run with multiple packages", continue-on-failure = true },
{ argv = ["vp", "dlx", "-s", "-p", "vp-test-echo", "-p", "vp-test-upper", "-c", "echo hello-from-shell | vp-test-echo | vp-test-upper"], comment = "should run shell mode command (vp's own shell handles the pipe)", continue-on-failure = true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ should run specific version
hello
```

## `npm_config_package=vp-test-upper vp dlx -s vp-test-echo@1.0.0 hello`

should ignore `npm_config_package` from an outer `npx --package`

```
hello
```

## `vp dlx -s @vp-test/cli@npm:vp-test-echo@1.0.0 hello`

npm selects the binary rather than using the scoped alias name
Expand Down
3 changes: 3 additions & 0 deletions crates/vp_pm_cli/src/resolution/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl ResolvedCommand {
if matches!(program.as_str(), "npm" | "npx") {
// Include npm/npx fallbacks: Vite+ manages their versions too.
env.insert("npm_config_update_notifier".to_string(), "false".to_string());
// `npx --package=vite-plus vp ...` exports `npm_config_package`. If inherited,
// `npm exec -- <spec>` runs `<spec>` as a bin of that package instead.
env.insert("npm_config_package".to_string(), String::new());
}
Self { program, args: Vec::new(), env, pre_run: Vec::new() }
}
Expand Down
10 changes: 10 additions & 0 deletions crates/vp_pm_cli/src/resolution/commands/dlx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ mod tests {
assert_eq!(command.args, vec!["exec", "--yes", "--", "@angular/cli", "--version"]);
}

#[test]
fn test_npm_clears_inherited_package_config() {
for version in ["6.14.18", "11.0.0"] {
let command =
expect_run(resolve(&npm(version), dlx_args("vp-test-echo@1.0.0", &[])).outcome);

assert_eq!(command.env.get("npm_config_package").map(String::as_str), Some(""));
}
}

#[test]
fn test_yarn_v1_fallback_to_npx() {
let resolution = resolve(&yarn("1.22.19"), dlx_args("create-vue", &["my-app"]));
Expand Down
Loading