summaryrefslogtreecommitdiff
path: root/cli/flags.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-10-06 19:07:04 +0200
committerGitHub <noreply@github.com>2021-10-06 19:07:04 +0200
commitb686907a45bb7d113f863cca7c52754027e449c0 (patch)
tree9bc296cc2ade609c4276fce1f14128338c0e6f1f /cli/flags.rs
parentb033a7a6d4ac6f1d3e20b5d113cca2fd85cacfc3 (diff)
feat(compat): inject Node globals (#12342)
This commit adds automatic injection of Node globals when "--compat" flag is present. This is done by executing "https://deno.land/std/node/global.ts" as a "side module", before main module is executed. This commit makes "--compat" required to be used with "--unstable" flag, as some of Node globals require unstable Deno APIs.
Diffstat (limited to 'cli/flags.rs')
-rw-r--r--cli/flags.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index 3075eda40..df17c08da 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -1627,7 +1627,8 @@ fn seed_arg<'a, 'b>() -> Arg<'a, 'b> {
fn compat_arg<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("compat")
.long("compat")
- .help("Node compatibility mode. Currently only enables built-in node modules like 'fs'.")
+ .requires("unstable")
+ .help("Node compatibility mode. Currently only enables built-in node modules like 'fs' and globals like 'process'.")
}
fn watch_arg<'a, 'b>() -> Arg<'a, 'b> {
@@ -4453,7 +4454,8 @@ mod tests {
#[test]
fn compat() {
- let r = flags_from_vec(svec!["deno", "run", "--compat", "foo.js"]);
+ let r =
+ flags_from_vec(svec!["deno", "run", "--compat", "--unstable", "foo.js"]);
assert_eq!(
r.unwrap(),
Flags {
@@ -4461,6 +4463,7 @@ mod tests {
script: "foo.js".to_string(),
}),
compat: true,
+ unstable: true,
..Flags::default()
}
);