mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 19:08:15 +00:00
feat(cli): add nodeModulesDir
option to config file (#19095)
This adds an option to disable or enable using a local `node_modules` directory as a project wide setting. https://github.com/denoland/manual/pull/659 Closes #17930
This commit is contained in:
parent
a45f7f237b
commit
680ae31db8
5 changed files with 47 additions and 4 deletions
|
@ -1880,3 +1880,34 @@ fn binary_package_with_optional_dependencies() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn node_modules_dir_config_file() {
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let temp_dir = test_context.temp_dir();
|
||||
let node_modules_dir = temp_dir.path().join("node_modules");
|
||||
let rm_node_modules = || std::fs::remove_dir_all(&node_modules_dir).unwrap();
|
||||
|
||||
temp_dir.write("deno.json", r#"{ "nodeModulesDir": true }"#);
|
||||
temp_dir.write("main.ts", "import 'npm:@denotest/esm-basic';");
|
||||
|
||||
let deno_cache_cmd = test_context.new_command().args("cache --quiet main.ts");
|
||||
deno_cache_cmd.run();
|
||||
|
||||
assert!(node_modules_dir.exists());
|
||||
rm_node_modules();
|
||||
temp_dir.write("deno.json", r#"{ "nodeModulesDir": false }"#);
|
||||
|
||||
deno_cache_cmd.run();
|
||||
assert!(!node_modules_dir.exists());
|
||||
|
||||
temp_dir.write("package.json", r#"{}"#);
|
||||
deno_cache_cmd.run();
|
||||
assert!(!node_modules_dir.exists());
|
||||
|
||||
test_context
|
||||
.new_command()
|
||||
.args("cache --quiet --node-modules-dir main.ts")
|
||||
.run();
|
||||
assert!(node_modules_dir.exists());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue