diff options
Diffstat (limited to 'cli/ops')
-rw-r--r-- | cli/ops/compiler.rs | 30 | ||||
-rw-r--r-- | cli/ops/errors.rs | 7 | ||||
-rw-r--r-- | cli/ops/runtime_compiler.rs | 32 |
3 files changed, 22 insertions, 47 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs index c66b56d43..d93a0edf4 100644 --- a/cli/ops/compiler.rs +++ b/cli/ops/compiler.rs @@ -13,7 +13,6 @@ use deno_core::ZeroCopyBuf; use futures::future::FutureExt; pub fn init(i: &mut CoreIsolate, s: &State) { - i.register_op("op_cache", s.stateful_json_op(op_cache)); i.register_op("op_resolve_modules", s.stateful_json_op(op_resolve_modules)); i.register_op( "op_fetch_source_files", @@ -26,35 +25,6 @@ pub fn init(i: &mut CoreIsolate, s: &State) { ); } -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct CacheArgs { - module_id: String, - contents: String, - extension: String, -} - -fn op_cache( - state: &State, - args: Value, - _zero_copy: Option<ZeroCopyBuf>, -) -> Result<JsonOp, OpError> { - let args: CacheArgs = serde_json::from_value(args)?; - - let module_specifier = ModuleSpecifier::resolve_url(&args.module_id) - .expect("Should be valid module specifier"); - - let state_ = &state.borrow().global_state; - let ts_compiler = state_.ts_compiler.clone(); - ts_compiler.cache_compiler_output( - &module_specifier, - &args.extension, - &args.contents, - )?; - - Ok(JsonOp::Sync(json!({}))) -} - #[derive(Deserialize, Debug)] struct SpecifiersReferrerArgs { specifiers: Vec<String>, diff --git a/cli/ops/errors.rs b/cli/ops/errors.rs index 3e48fd007..766c130e2 100644 --- a/cli/ops/errors.rs +++ b/cli/ops/errors.rs @@ -57,9 +57,6 @@ fn op_format_diagnostic( args: Value, _zero_copy: Option<ZeroCopyBuf>, ) -> Result<JsonOp, OpError> { - if let Some(diagnostic) = Diagnostic::from_json_value(&args) { - Ok(JsonOp::Sync(json!(diagnostic.to_string()))) - } else { - Err(OpError::type_error("bad diagnostic".to_string())) - } + let diagnostic = serde_json::from_value::<Diagnostic>(args)?; + Ok(JsonOp::Sync(json!(diagnostic.to_string()))) } diff --git a/cli/ops/runtime_compiler.rs b/cli/ops/runtime_compiler.rs index 4c4110e1e..c7225b944 100644 --- a/cli/ops/runtime_compiler.rs +++ b/cli/ops/runtime_compiler.rs @@ -2,6 +2,7 @@ use super::dispatch_json::{Deserialize, JsonOp, Value}; use crate::compilers::runtime_compile; use crate::compilers::runtime_transpile; +use crate::futures::FutureExt; use crate::op_error::OpError; use crate::state::State; use deno_core::CoreIsolate; @@ -29,13 +30,19 @@ fn op_compile( ) -> Result<JsonOp, OpError> { state.check_unstable("Deno.compile"); let args: CompileArgs = serde_json::from_value(args)?; - Ok(JsonOp::Async(runtime_compile( - state.borrow().global_state.clone(), - &args.root_name, - &args.sources, - args.bundle, - &args.options, - ))) + let global_state = state.borrow().global_state.clone(); + let fut = async move { + runtime_compile( + global_state, + &args.root_name, + &args.sources, + args.bundle, + &args.options, + ) + .await + } + .boxed_local(); + Ok(JsonOp::Async(fut)) } #[derive(Deserialize, Debug)] @@ -51,9 +58,10 @@ fn op_transpile( ) -> Result<JsonOp, OpError> { state.check_unstable("Deno.transpile"); let args: TranspileArgs = serde_json::from_value(args)?; - Ok(JsonOp::Async(runtime_transpile( - state.borrow().global_state.clone(), - &args.sources, - &args.options, - ))) + let global_state = state.borrow().global_state.clone(); + let fut = async move { + runtime_transpile(global_state, &args.sources, &args.options).await + } + .boxed_local(); + Ok(JsonOp::Async(fut)) } |