mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(task): do not eagerly auto-install packages in package.json when "nodeModulesDir": false
(#21858)
There's no need to auto-install the package.json if the user is not using a node_modules directory. Closes #21850
This commit is contained in:
parent
0efb17b2cb
commit
be888c068c
5 changed files with 33 additions and 4 deletions
|
@ -178,6 +178,18 @@ itest!(task_package_json_npm_bin {
|
||||||
http_server: true,
|
http_server: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// should not auto-install the packages in the package.json
|
||||||
|
// when using nodeModulesDir: false
|
||||||
|
itest!(task_package_json_node_modules_dir_false {
|
||||||
|
args: "task echo",
|
||||||
|
cwd: Some("task/package_json_node_modules_dir_false/"),
|
||||||
|
output: "task/package_json_node_modules_dir_false/bin.out",
|
||||||
|
copy_temp_dir: Some("task/package_json_node_modules_dir_false/"),
|
||||||
|
envs: env_vars_for_npm_tests(),
|
||||||
|
exit_code: 0,
|
||||||
|
http_server: true,
|
||||||
|
});
|
||||||
|
|
||||||
itest!(task_both_no_arg {
|
itest!(task_both_no_arg {
|
||||||
args: "task",
|
args: "task",
|
||||||
cwd: Some("task/both/"),
|
cwd: Some("task/both/"),
|
||||||
|
|
2
cli/tests/testdata/task/package_json_node_modules_dir_false/bin.out
vendored
Normal file
2
cli/tests/testdata/task/package_json_node_modules_dir_false/bin.out
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Task echo deno eval 'console.log(1)'
|
||||||
|
1
|
3
cli/tests/testdata/task/package_json_node_modules_dir_false/deno.json
vendored
Normal file
3
cli/tests/testdata/task/package_json_node_modules_dir_false/deno.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"nodeModulesDir": false
|
||||||
|
}
|
9
cli/tests/testdata/task/package_json_node_modules_dir_false/package.json
vendored
Normal file
9
cli/tests/testdata/task/package_json_node_modules_dir_false/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"scripts": {
|
||||||
|
"echo": "deno eval 'console.log(1)'"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@denotest/bin": "0.5",
|
||||||
|
"other": "npm:@denotest/bin@1.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -88,10 +88,13 @@ pub async fn execute_script(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// install the npm packages if we're using a managed resolver
|
// ensure the npm packages are installed if using a node_modules
|
||||||
if let Some(npm_resolver) = npm_resolver.as_managed() {
|
// directory and managed resolver
|
||||||
npm_resolver.ensure_top_level_package_json_install().await?;
|
if cli_options.has_node_modules_dir() {
|
||||||
npm_resolver.resolve_pending().await?;
|
if let Some(npm_resolver) = npm_resolver.as_managed() {
|
||||||
|
npm_resolver.ensure_top_level_package_json_install().await?;
|
||||||
|
npm_resolver.resolve_pending().await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let cwd = match task_flags.cwd {
|
let cwd = match task_flags.cwd {
|
||||||
|
|
Loading…
Reference in a new issue