summaryrefslogtreecommitdiff
path: root/cli/args
diff options
context:
space:
mode:
Diffstat (limited to 'cli/args')
-rw-r--r--cli/args/config_file.rs7
-rw-r--r--cli/args/flags.rs2
-rw-r--r--cli/args/mod.rs7
3 files changed, 12 insertions, 4 deletions
diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs
index 8b52d7825..ed31a47a6 100644
--- a/cli/args/config_file.rs
+++ b/cli/args/config_file.rs
@@ -668,12 +668,13 @@ pub struct ConfigFileJson {
pub bench: Option<Value>,
pub lock: Option<Value>,
pub exclude: Option<Value>,
+ pub node_modules_dir: Option<bool>,
}
#[derive(Clone, Debug)]
pub struct ConfigFile {
pub specifier: ModuleSpecifier,
- pub json: ConfigFileJson,
+ json: ConfigFileJson,
}
impl ConfigFile {
@@ -865,6 +866,10 @@ impl ConfigFile {
self.json.import_map.clone()
}
+ pub fn node_modules_dir(&self) -> Option<bool> {
+ self.json.node_modules_dir
+ }
+
pub fn to_import_map_value(&self) -> Value {
let mut value = serde_json::Map::with_capacity(2);
if let Some(imports) = &self.json.imports {
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index fa28241a3..63ec2b947 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -2431,7 +2431,7 @@ fn local_npm_arg() -> Arg {
.value_parser(value_parser!(bool))
.default_missing_value("true")
.require_equals(true)
- .help("Creates a local node_modules folder")
+ .help("Enables or disables the use of a local node_modules folder for npm packages")
}
fn unsafely_ignore_certificate_errors_arg() -> Arg {
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 53dad9cae..fef27f464 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -1184,14 +1184,17 @@ fn resolve_local_node_modules_folder(
maybe_config_file: Option<&ConfigFile>,
maybe_package_json: Option<&PackageJson>,
) -> Result<Option<PathBuf>, AnyError> {
- let path = if flags.node_modules_dir == Some(false) {
+ let use_node_modules_dir = flags
+ .node_modules_dir
+ .or_else(|| maybe_config_file.and_then(|c| c.node_modules_dir()));
+ let path = if use_node_modules_dir == Some(false) {
return Ok(None);
} else if let Some(state) = &*NPM_PROCESS_STATE {
return Ok(state.local_node_modules_path.as_ref().map(PathBuf::from));
} else if let Some(package_json_path) = maybe_package_json.map(|c| &c.path) {
// always auto-discover the local_node_modules_folder when a package.json exists
package_json_path.parent().unwrap().join("node_modules")
- } else if flags.node_modules_dir.is_none() {
+ } else if use_node_modules_dir.is_none() {
return Ok(None);
} else if let Some(config_path) = maybe_config_file
.as_ref()