mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
refactor(cli/ops): don't pass ops through json (#10629)
This commit is contained in:
parent
608c7d68e2
commit
b0e30dbbc6
1 changed files with 7 additions and 13 deletions
|
@ -2,9 +2,6 @@ use crate::tools::test_runner::TestEvent;
|
|||
use crate::tools::test_runner::TestMessage;
|
||||
use deno_core::error::generic_error;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::json;
|
||||
use deno_core::serde_json::Value;
|
||||
use deno_core::JsRuntime;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_core::OpState;
|
||||
|
@ -30,17 +27,15 @@ struct PermissionsHolder(Uuid, Permissions);
|
|||
|
||||
pub fn op_pledge_test_permissions(
|
||||
state: &mut OpState,
|
||||
args: Value,
|
||||
args: PermissionsArg,
|
||||
_: (),
|
||||
) -> Result<Uuid, AnyError> {
|
||||
deno_runtime::ops::check_unstable(state, "Deno.test.permissions");
|
||||
|
||||
let token = Uuid::new_v4();
|
||||
let parent_permissions = state.borrow::<Permissions>().clone();
|
||||
let worker_permissions = {
|
||||
let permissions: PermissionsArg = serde_json::from_value(args)?;
|
||||
create_worker_permissions(parent_permissions.clone(), permissions)?
|
||||
};
|
||||
let worker_permissions =
|
||||
create_worker_permissions(parent_permissions.clone(), args)?;
|
||||
|
||||
state.put::<PermissionsHolder>(PermissionsHolder(token, parent_permissions));
|
||||
|
||||
|
@ -78,10 +73,9 @@ struct PostTestMessageArgs {
|
|||
|
||||
fn op_post_test_message(
|
||||
state: &mut OpState,
|
||||
args: Value,
|
||||
args: PostTestMessageArgs,
|
||||
_: (),
|
||||
) -> Result<Value, AnyError> {
|
||||
let args: PostTestMessageArgs = serde_json::from_value(args)?;
|
||||
) -> Result<bool, AnyError> {
|
||||
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
||||
let message = args.message;
|
||||
|
||||
|
@ -90,8 +84,8 @@ fn op_post_test_message(
|
|||
let sender = state.borrow::<Sender<TestEvent>>().clone();
|
||||
|
||||
if sender.send(event).is_err() {
|
||||
Ok(json!(false))
|
||||
Ok(false)
|
||||
} else {
|
||||
Ok(json!(true))
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue