diff options
Diffstat (limited to 'ext/fs/lib.rs')
-rw-r--r-- | ext/fs/lib.rs | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs index b028b12c1..ab19540b5 100644 --- a/ext/fs/lib.rs +++ b/ext/fs/lib.rs @@ -18,9 +18,7 @@ use crate::ops::*; use deno_core::error::AnyError; use deno_core::OpState; -use std::cell::RefCell; use std::path::Path; -use std::rc::Rc; pub trait FsPermissions { fn check_read(&mut self, path: &Path, api_name: &str) @@ -66,31 +64,11 @@ pub trait FsPermissions { } } -struct UnstableChecker { - pub unstable: bool, -} - -impl UnstableChecker { - // NOTE(bartlomieju): keep in sync with `cli/program_state.rs` - pub fn check_unstable(&self, api_name: &str) { - if !self.unstable { - eprintln!( - "Unstable API '{api_name}'. The --unstable flag must be provided." - ); - std::process::exit(70); - } - } -} - /// Helper for checking unstable features. Used for sync ops. -pub(crate) fn check_unstable(state: &OpState, api_name: &str) { - state.borrow::<UnstableChecker>().check_unstable(api_name) -} - -/// Helper for checking unstable features. Used for async ops. -pub(crate) fn check_unstable2(state: &Rc<RefCell<OpState>>, api_name: &str) { - let state = state.borrow(); - state.borrow::<UnstableChecker>().check_unstable(api_name) +fn check_unstable(state: &OpState, api_name: &str) { + state + .feature_checker + .check_legacy_unstable_or_exit(api_name); } deno_core::extension!(deno_fs, @@ -164,11 +142,9 @@ deno_core::extension!(deno_fs, ], esm = [ "30_fs.js" ], options = { - unstable: bool, fs: FileSystemRc, }, state = |state, options| { - state.put(UnstableChecker { unstable: options.unstable }); state.put(options.fs); }, ); |