diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-09-20 01:17:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-20 01:17:35 +0200 |
commit | b657d743a22802b8232fbf558f2f00bf2942096f (patch) | |
tree | e3a3047e78b6bd9c9e3f551f99f5e80e32de079d /cli/ops/process.rs | |
parent | aaa5e6613a739f8e2ff7579b69c2504bcdc37d4f (diff) |
refactor: remove CliState, use OpState, add CliModuleLoader (#7588)
- remove "CliState.workers" and "CliState.next_worker_id", instead
store them on "OpState" using type aliases.
- remove "CliState.global_timer" and "CliState.start_time", instead
store them on "OpState" using type aliases.
- remove "CliState.is_internal", instead pass it to Worker::new
- move "CliState::permissions" to "OpState"
- move "CliState::main_module" to "OpState"
- move "CliState::global_state" to "OpState"
- move "CliState::check_unstable()" to "GlobalState"
- change "cli_state()" to "global_state()"
- change "deno_core::ModuleLoader" trait to pass "OpState" to callbacks
- rename "CliState" to "CliModuleLoader"
Diffstat (limited to 'cli/ops/process.rs')
-rw-r--r-- | cli/ops/process.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cli/ops/process.rs b/cli/ops/process.rs index 3a7db8249..5099889cd 100644 --- a/cli/ops/process.rs +++ b/cli/ops/process.rs @@ -1,6 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use super::io::{std_file_resource, StreamResource, StreamResourceHolder}; +use crate::permissions::Permissions; use crate::signal::kill; use deno_core::error::bad_resource_id; use deno_core::error::type_error; @@ -68,7 +69,7 @@ fn op_run( _zero_copy: &mut [ZeroCopyBuf], ) -> Result<Value, AnyError> { let run_args: RunArgs = serde_json::from_value(args)?; - super::cli_state(state).check_run()?; + state.borrow::<Permissions>().check_run()?; let args = run_args.cmd; let env = run_args.env; @@ -178,7 +179,10 @@ async fn op_run_status( let args: RunStatusArgs = serde_json::from_value(args)?; let rid = args.rid as u32; - super::cli_state2(&state).check_run()?; + { + let s = state.borrow(); + s.borrow::<Permissions>().check_run()?; + } let run_status = poll_fn(|cx| { let mut state = state.borrow_mut(); @@ -221,9 +225,9 @@ fn op_kill( args: Value, _zero_copy: &mut [ZeroCopyBuf], ) -> Result<Value, AnyError> { - let cli_state = super::cli_state(state); + let cli_state = super::global_state(state); cli_state.check_unstable("Deno.kill"); - cli_state.check_run()?; + state.borrow::<Permissions>().check_run()?; let args: KillArgs = serde_json::from_value(args)?; kill(args.pid, args.signo)?; |