summaryrefslogtreecommitdiff
path: root/cli/args/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-12-08 11:50:09 -0500
committerGitHub <noreply@github.com>2022-12-08 11:50:09 -0500
commit91443bbc0b3e5420d8a0b3506f1b18a88d48560a (patch)
tree804e60461874a71af08760f3aa1809c782558ac0 /cli/args/mod.rs
parenta6b5d05311f54d085a1e44f4a51717b4c0a4c74b (diff)
fix(compile): ensure import map is used when specified in deno config file (#16990)
Closes #14246
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r--cli/args/mod.rs50
1 files changed, 42 insertions, 8 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 38e0abea0..3f3f53d18 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -176,7 +176,7 @@ struct CliOptionOverrides {
import_map_specifier: Option<Option<ModuleSpecifier>>,
}
-/// Holds the common options used by many sub commands
+/// Holds the resolved options of many sources used by sub commands
/// and provides some helper function for creating common objects.
pub struct CliOptions {
// the source of the options is a detail the rest of the
@@ -414,6 +414,14 @@ impl CliOptions {
&self.flags.argv
}
+ pub fn ca_file(&self) -> &Option<String> {
+ &self.flags.ca_file
+ }
+
+ pub fn ca_stores(&self) -> &Option<Vec<String>> {
+ &self.flags.ca_stores
+ }
+
pub fn check_js(&self) -> bool {
self
.maybe_config_file
@@ -467,8 +475,8 @@ impl CliOptions {
.unwrap_or(false)
}
- pub fn location_flag(&self) -> Option<&Url> {
- self.flags.location.as_ref()
+ pub fn location_flag(&self) -> &Option<Url> {
+ &self.flags.location
}
pub fn maybe_custom_root(&self) -> Option<PathBuf> {
@@ -483,6 +491,10 @@ impl CliOptions {
self.flags.no_clear_screen
}
+ pub fn no_prompt(&self) -> bool {
+ resolve_no_prompt(&self.flags)
+ }
+
pub fn no_remote(&self) -> bool {
self.flags.no_remote
}
@@ -492,7 +504,17 @@ impl CliOptions {
}
pub fn permissions_options(&self) -> PermissionsOptions {
- self.flags.permissions_options()
+ PermissionsOptions {
+ allow_env: self.flags.allow_env.clone(),
+ allow_hrtime: self.flags.allow_hrtime,
+ allow_net: self.flags.allow_net.clone(),
+ allow_ffi: self.flags.allow_ffi.clone(),
+ allow_read: self.flags.allow_read.clone(),
+ allow_run: self.flags.allow_run.clone(),
+ allow_sys: self.flags.allow_sys.clone(),
+ allow_write: self.flags.allow_write.clone(),
+ prompt: !self.no_prompt(),
+ }
}
pub fn reload_flag(&self) -> bool {
@@ -525,16 +547,20 @@ impl CliOptions {
self.flags.type_check_mode
}
- pub fn unsafely_ignore_certificate_errors(&self) -> Option<&Vec<String>> {
- self.flags.unsafely_ignore_certificate_errors.as_ref()
+ pub fn unsafely_ignore_certificate_errors(&self) -> &Option<Vec<String>> {
+ &self.flags.unsafely_ignore_certificate_errors
}
pub fn unstable(&self) -> bool {
self.flags.unstable
}
- pub fn watch_paths(&self) -> Option<&Vec<PathBuf>> {
- self.flags.watch.as_ref()
+ pub fn v8_flags(&self) -> &Vec<String> {
+ &self.flags.v8_flags
+ }
+
+ pub fn watch_paths(&self) -> &Option<Vec<PathBuf>> {
+ &self.flags.watch
}
}
@@ -590,6 +616,14 @@ fn resolve_import_map_specifier(
Ok(None)
}
+/// Resolves the no_prompt value based on the cli flags and environment.
+pub fn resolve_no_prompt(flags: &Flags) -> bool {
+ flags.no_prompt || {
+ let value = env::var("DENO_NO_PROMPT");
+ matches!(value.as_ref().map(|s| s.as_str()), Ok("1"))
+ }
+}
+
#[cfg(test)]
mod test {
use super::*;