diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-08-30 11:11:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-30 11:11:33 -0400 |
commit | c370f749b2260cc1d8970b1dcdc63ff00008e26d (patch) | |
tree | 1eff43e71ca0a5ccaeb48a3bf891bf2fdc0712ba /cli/ops/compiler.rs | |
parent | 5401cb76304ae8d3e8896f6020ba4ef25bac0bba (diff) |
Remove ts_library_builder, maintain lib.deno_runtime.d.ts by hand (#2827)
Diffstat (limited to 'cli/ops/compiler.rs')
-rw-r--r-- | cli/ops/compiler.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs index 39d3a6d7f..40d25aa74 100644 --- a/cli/ops/compiler.rs +++ b/cli/ops/compiler.rs @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. use super::dispatch_json::{Deserialize, JsonOp, Value}; +use crate::assets; use crate::state::ThreadSafeState; use crate::tokio_util; use deno::*; @@ -66,3 +67,21 @@ pub fn op_fetch_source_file( "sourceCode": String::from_utf8(out.source_code).unwrap(), }))) } + +#[derive(Deserialize)] +struct FetchAssetArgs { + name: String, +} + +pub fn op_fetch_asset( + _state: &ThreadSafeState, + args: Value, + _zero_copy: Option<PinnedBuf>, +) -> Result<JsonOp, ErrBox> { + let args: FetchAssetArgs = serde_json::from_value(args)?; + if let Some(source_code) = assets::get_source_code(&args.name) { + Ok(JsonOp::Sync(json!(source_code))) + } else { + panic!("op_fetch_asset bad asset {}", args.name) + } +} |