diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-09-27 22:36:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-27 22:36:33 +0200 |
commit | 212b7dd6da487c070229b6348ec7907b4fecbcf9 (patch) | |
tree | 3eb743f90e8b293182a830722eb4ff26bec72039 /runtime/ops/spawn.rs | |
parent | a344368603063bcb281e743f3810ca1e4e46e85d (diff) |
feat: Add requesting API name to permission prompt (#15936)
Co-authored-by: Leo Kettmeir <crowlkats@toaxl.com>
Diffstat (limited to 'runtime/ops/spawn.rs')
-rw-r--r-- | runtime/ops/spawn.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs index b337f2488..9286e6d0c 100644 --- a/runtime/ops/spawn.rs +++ b/runtime/ops/spawn.rs @@ -122,9 +122,13 @@ pub struct SpawnOutput { fn create_command( state: &mut OpState, args: SpawnArgs, + api_name: &str, ) -> Result<std::process::Command, AnyError> { super::check_unstable(state, "Deno.spawn"); - state.borrow_mut::<Permissions>().run.check(&args.cmd)?; + state + .borrow_mut::<Permissions>() + .run + .check(&args.cmd, Some(api_name))?; let mut command = std::process::Command::new(args.cmd); command.args(args.args); @@ -185,8 +189,10 @@ struct Child { fn op_spawn_child( state: &mut OpState, args: SpawnArgs, + api_name: String, ) -> Result<Child, AnyError> { - let mut command = tokio::process::Command::from(create_command(state, args)?); + let mut command = + tokio::process::Command::from(create_command(state, args, &api_name)?); // TODO(@crowlkats): allow detaching processes. // currently deno will orphan a process when exiting with an error or Deno.exit() // We want to kill child when it's closed @@ -246,7 +252,7 @@ fn op_spawn_sync( ) -> Result<SpawnOutput, AnyError> { let stdout = matches!(args.stdio.stdout, Stdio::Piped); let stderr = matches!(args.stdio.stderr, Stdio::Piped); - let output = create_command(state, args)?.output()?; + let output = create_command(state, args, "Deno.spawnSync()")?.output()?; Ok(SpawnOutput { status: output.status.try_into()?, |