summaryrefslogtreecommitdiff
path: root/cli/global_state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/global_state.rs')
-rw-r--r--cli/global_state.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/cli/global_state.rs b/cli/global_state.rs
index 700909f8f..52bf48593 100644
--- a/cli/global_state.rs
+++ b/cli/global_state.rs
@@ -10,7 +10,6 @@ use crate::media_type::MediaType;
use crate::module_graph::ModuleGraphFile;
use crate::module_graph::ModuleGraphLoader;
use crate::permissions::Permissions;
-use crate::state::exit_unstable;
use crate::tsc::CompiledModule;
use crate::tsc::TargetLib;
use crate::tsc::TsCompiler;
@@ -22,6 +21,14 @@ use std::sync::Arc;
use std::sync::Mutex;
use tokio::sync::Mutex as AsyncMutex;
+pub fn exit_unstable(api_name: &str) {
+ eprintln!(
+ "Unstable API '{}'. The --unstable flag must be provided.",
+ api_name
+ );
+ std::process::exit(70);
+}
+
/// This structure represents state of single "deno" program.
///
/// It is shared by all created workers (thus V8 isolates).
@@ -235,6 +242,16 @@ impl GlobalState {
Ok(compiled_module)
}
+ /// Quits the process if the --unstable flag was not provided.
+ ///
+ /// This is intentionally a non-recoverable check so that people cannot probe
+ /// for unstable APIs from stable programs.
+ pub fn check_unstable(&self, api_name: &str) {
+ if !self.flags.unstable {
+ exit_unstable(api_name);
+ }
+ }
+
#[cfg(test)]
pub fn mock(
argv: Vec<String>,