diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-10-21 00:23:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-21 00:23:57 +0200 |
commit | 8a0e206ede0f5cc7c21312688e86a1157edb4bcf (patch) | |
tree | 5eed1c9550a82c745c6ad2e6f3f3e2f527afcf68 /cli/compat/mod.rs | |
parent | 46bc1175e51d64fce623b8e4c4b846ed02d19bea (diff) |
compat: add DENO_NODE_COMPAT_URL env variable (#12508)
Diffstat (limited to 'cli/compat/mod.rs')
-rw-r--r-- | cli/compat/mod.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cli/compat/mod.rs b/cli/compat/mod.rs index b95b65ddb..ad820c14c 100644 --- a/cli/compat/mod.rs +++ b/cli/compat/mod.rs @@ -62,9 +62,11 @@ static SUPPORTED_MODULES: &[&str] = &[ ]; lazy_static::lazy_static! { - static ref GLOBAL_URL_STR: String = format!("{}node/global.ts", STD_URL_STR); + static ref NODE_COMPAT_URL: String = std::env::var("DENO_NODE_COMPAT_URL").map(String::into).ok() + .unwrap_or_else(|| STD_URL_STR.to_string()); + static ref GLOBAL_URL_STR: String = format!("{}node/global.ts", NODE_COMPAT_URL.as_str()); pub(crate) static ref GLOBAL_URL: Url = Url::parse(&GLOBAL_URL_STR).unwrap(); - static ref MODULE_URL_STR: String = format!("{}node/module.ts", STD_URL_STR); + static ref MODULE_URL_STR: String = format!("{}node/module.ts", NODE_COMPAT_URL.as_str()); pub(crate) static ref MODULE_URL: Url = Url::parse(&MODULE_URL_STR).unwrap(); static ref COMPAT_IMPORT_URL: Url = Url::parse("flags:compat").unwrap(); } @@ -76,7 +78,8 @@ pub(crate) fn get_node_imports() -> Vec<(Url, Vec<String>)> { fn try_resolve_builtin_module(specifier: &str) -> Option<Url> { if SUPPORTED_MODULES.contains(&specifier) { - let module_url = format!("{}node/{}.ts", STD_URL_STR, specifier); + let module_url = + format!("{}node/{}.ts", NODE_COMPAT_URL.as_str(), specifier); Some(Url::parse(&module_url).unwrap()) } else { None |