summaryrefslogtreecommitdiff
path: root/cli/args/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r--cli/args/mod.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 31035fdd0..53dad9cae 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -13,6 +13,7 @@ use self::package_json::PackageJsonDeps;
use ::import_map::ImportMap;
use deno_core::resolve_url_or_path;
use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
+use deno_npm::NpmSystemInfo;
use deno_runtime::deno_tls::RootCertStoreProvider;
use deno_semver::npm::NpmPackageReqReference;
use indexmap::IndexMap;
@@ -688,6 +689,42 @@ impl CliOptions {
}
}
+ pub fn npm_system_info(&self) -> NpmSystemInfo {
+ match self.sub_command() {
+ DenoSubcommand::Compile(CompileFlags {
+ target: Some(target),
+ ..
+ }) => {
+ // the values of NpmSystemInfo align with the possible values for the
+ // `arch` and `platform` fields of Node.js' `process` global:
+ // https://nodejs.org/api/process.html
+ match target.as_str() {
+ "aarch64-apple-darwin" => NpmSystemInfo {
+ os: "darwin".to_string(),
+ cpu: "arm64".to_string(),
+ },
+ "x86_64-apple-darwin" => NpmSystemInfo {
+ os: "darwin".to_string(),
+ cpu: "x64".to_string(),
+ },
+ "x86_64-unknown-linux-gnu" => NpmSystemInfo {
+ os: "linux".to_string(),
+ cpu: "x64".to_string(),
+ },
+ "x86_64-pc-windows-msvc" => NpmSystemInfo {
+ os: "win32".to_string(),
+ cpu: "x64".to_string(),
+ },
+ value => {
+ log::warn!("Not implemented NPM system info for target '{value}'. Using current system default. This may impact NPM ");
+ NpmSystemInfo::default()
+ }
+ }
+ }
+ _ => NpmSystemInfo::default(),
+ }
+ }
+
pub fn resolve_deno_dir(&self) -> Result<DenoDir, AnyError> {
Ok(DenoDir::new(self.maybe_custom_root())?)
}