1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -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:
David Sherret 2024-01-08 19:30:36 -05:00 committed by GitHub
parent 0efb17b2cb
commit be888c068c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 4 deletions

View file

@ -178,6 +178,18 @@ itest!(task_package_json_npm_bin {
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 {
args: "task",
cwd: Some("task/both/"),

View file

@ -0,0 +1,2 @@
Task echo deno eval 'console.log(1)'
1

View file

@ -0,0 +1,3 @@
{
"nodeModulesDir": false
}

View file

@ -0,0 +1,9 @@
{
"scripts": {
"echo": "deno eval 'console.log(1)'"
},
"dependencies": {
"@denotest/bin": "0.5",
"other": "npm:@denotest/bin@1.0"
}
}

View file

@ -88,10 +88,13 @@ pub async fn execute_script(
}
}
// install the npm packages if we're using a managed resolver
if let Some(npm_resolver) = npm_resolver.as_managed() {
npm_resolver.ensure_top_level_package_json_install().await?;
npm_resolver.resolve_pending().await?;
// ensure the npm packages are installed if using a node_modules
// directory and managed resolver
if cli_options.has_node_modules_dir() {
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 {