summaryrefslogtreecommitdiff
path: root/cli/ops/compiler.rs
diff options
context:
space:
mode:
authorRy Dahl <ry@tinyclouds.org>2020-01-21 14:57:56 -0500
committerGitHub <noreply@github.com>2020-01-21 14:57:56 -0500
commitfa7f34eb8cec07f4c68ca4e9c46a983bc3e2308f (patch)
tree821263579dd75de3c16508fdecfdcaba52987373 /cli/ops/compiler.rs
parent7fd50065a7d8a4c6ed1b1090703a7baaabdbd6aa (diff)
Revert "Create an old program to be used in snapshot. (#3644)"
Ref #3712. This change allowed the deno_typescript crate to reference cli/js/lib.deno_runtime.d.ts which breaks "cargo package". We intend to reintroduce a revised version of this patch later once "cargo package" is working and tested. This reverts commit 737ab94ea1bdf65eeef323ea37e84bcf430fb92c.
Diffstat (limited to 'cli/ops/compiler.rs')
-rw-r--r--cli/ops/compiler.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs
index e515081df..cb2fb01a0 100644
--- a/cli/ops/compiler.rs
+++ b/cli/ops/compiler.rs
@@ -17,6 +17,10 @@ pub fn init(i: &mut Isolate, s: &ThreadSafeState) {
"fetch_source_files",
s.core_op(json_op(s.stateful_op(op_fetch_source_files))),
);
+ i.register_op(
+ "fetch_asset",
+ s.core_op(json_op(s.stateful_op(op_fetch_asset))),
+ );
}
#[derive(Deserialize)]
@@ -145,3 +149,21 @@ fn op_fetch_source_files(
Ok(JsonOp::Async(future))
}
+
+#[derive(Deserialize)]
+struct FetchAssetArgs {
+ name: String,
+}
+
+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) = crate::js::get_asset(&args.name) {
+ Ok(JsonOp::Sync(json!(source_code)))
+ } else {
+ panic!("op_fetch_asset bad asset {}", args.name)
+ }
+}