summaryrefslogtreecommitdiff
path: root/cli/args/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r--cli/args/flags.rs61
1 files changed, 57 insertions, 4 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs
index 5c87c5fbb..96dfbbaf5 100644
--- a/cli/args/flags.rs
+++ b/cli/args/flags.rs
@@ -372,6 +372,7 @@ pub struct Flags {
pub type_check_mode: TypeCheckMode,
pub config_flag: ConfigFlag,
pub node_modules_dir: Option<bool>,
+ pub deno_modules_dir: Option<bool>,
pub enable_testing_features: bool,
pub ext: Option<String>,
pub ignore: Vec<PathBuf>,
@@ -1445,6 +1446,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
.arg(config_arg())
.arg(import_map_arg())
.arg(node_modules_dir_arg())
+ .arg(deno_modules_dir_arg())
.arg(
Arg::new("json")
.long("json")
@@ -1988,6 +1990,7 @@ Remote modules and multiple modules may also be specified:
.arg(import_map_arg())
.arg(lock_arg())
.arg(node_modules_dir_arg())
+ .arg(deno_modules_dir_arg())
.arg(reload_arg())
.arg(ca_file_arg()))
}
@@ -2002,6 +2005,7 @@ fn compile_args_without_check_args(app: Command) -> Command {
.arg(no_remote_arg())
.arg(no_npm_arg())
.arg(node_modules_dir_arg())
+ .arg(deno_modules_dir_arg())
.arg(config_arg())
.arg(no_config_arg())
.arg(reload_arg())
@@ -2560,6 +2564,16 @@ fn node_modules_dir_arg() -> Arg {
.help("Enables or disables the use of a local node_modules folder for npm packages")
}
+fn deno_modules_dir_arg() -> Arg {
+ Arg::new("deno-modules-dir")
+ .long("deno-modules-dir")
+ .num_args(0..=1)
+ .value_parser(value_parser!(bool))
+ .default_missing_value("true")
+ .require_equals(true)
+ .help("UNSTABLE: Enables or disables the use of a local deno_modules folder for remote modules")
+}
+
fn unsafely_ignore_certificate_errors_arg() -> Arg {
Arg::new("unsafely-ignore-certificate-errors")
.long("unsafely-ignore-certificate-errors")
@@ -2847,7 +2861,7 @@ fn info_parse(flags: &mut Flags, matches: &mut ArgMatches) {
import_map_arg_parse(flags, matches);
location_arg_parse(flags, matches);
ca_file_arg_parse(flags, matches);
- node_modules_dir_arg_parse(flags, matches);
+ node_and_deno_modules_dir_arg_parse(flags, matches);
lock_arg_parse(flags, matches);
no_lock_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
@@ -3107,7 +3121,7 @@ fn vendor_parse(flags: &mut Flags, matches: &mut ArgMatches) {
config_args_parse(flags, matches);
import_map_arg_parse(flags, matches);
lock_arg_parse(flags, matches);
- node_modules_dir_arg_parse(flags, matches);
+ node_and_deno_modules_dir_arg_parse(flags, matches);
reload_arg_parse(flags, matches);
flags.subcommand = DenoSubcommand::Vendor(VendorFlags {
@@ -3133,7 +3147,7 @@ fn compile_args_without_check_parse(
import_map_arg_parse(flags, matches);
no_remote_arg_parse(flags, matches);
no_npm_arg_parse(flags, matches);
- node_modules_dir_arg_parse(flags, matches);
+ node_and_deno_modules_dir_arg_parse(flags, matches);
config_args_parse(flags, matches);
reload_arg_parse(flags, matches);
lock_args_parse(flags, matches);
@@ -3387,8 +3401,12 @@ fn no_npm_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
}
}
-fn node_modules_dir_arg_parse(flags: &mut Flags, matches: &mut ArgMatches) {
+fn node_and_deno_modules_dir_arg_parse(
+ flags: &mut Flags,
+ matches: &mut ArgMatches,
+) {
flags.node_modules_dir = matches.remove_one::<bool>("node-modules-dir");
+ flags.deno_modules_dir = matches.remove_one::<bool>("deno-modules-dir");
}
fn reload_arg_validate(urlstr: &str) -> Result<String, String> {
@@ -5724,6 +5742,41 @@ mod tests {
}
#[test]
+ fn deno_modules_dir() {
+ let r =
+ flags_from_vec(svec!["deno", "run", "--deno-modules-dir", "script.ts"]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Run(RunFlags {
+ script: "script.ts".to_string(),
+ watch: Default::default(),
+ }),
+ deno_modules_dir: Some(true),
+ ..Flags::default()
+ }
+ );
+
+ let r = flags_from_vec(svec![
+ "deno",
+ "run",
+ "--deno-modules-dir=false",
+ "script.ts"
+ ]);
+ assert_eq!(
+ r.unwrap(),
+ Flags {
+ subcommand: DenoSubcommand::Run(RunFlags {
+ script: "script.ts".to_string(),
+ watch: Default::default(),
+ }),
+ deno_modules_dir: Some(false),
+ ..Flags::default()
+ }
+ );
+ }
+
+ #[test]
fn cached_only() {
let r = flags_from_vec(svec!["deno", "run", "--cached-only", "script.ts"]);
assert_eq!(