1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-02 09:34:19 -04:00
denoland-deno/cli/ops/compiler.rs

28 lines
835 B
Rust
Raw Normal View History

2020-01-02 15:13:47 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2020-09-05 20:34:02 -04:00
use crate::state::State;
2020-09-05 20:34:02 -04:00
use deno_core::OpRegistry;
use std::rc::Rc;
use std::sync::Arc;
use std::sync::Mutex;
2019-08-26 08:50:21 -04:00
2020-09-05 20:34:02 -04:00
pub fn init(s: &Rc<State>, response: Arc<Mutex<Option<String>>>) {
let custom_assets = std::collections::HashMap::new();
// TODO(ry) use None.
// TODO(bartlomieju): is this op even required?
2020-09-05 20:34:02 -04:00
s.register_op(
2020-02-25 09:14:27 -05:00
"op_fetch_asset",
2020-07-20 19:49:57 -04:00
crate::op_fetch_asset::op_fetch_asset(custom_assets),
);
2020-09-05 20:34:02 -04:00
s.register_op_json_sync("op_compiler_respond", move |_state, args, _bufs| {
let mut response_slot = response.lock().unwrap();
let replaced_value = response_slot.replace(args.to_string());
assert!(
replaced_value.is_none(),
"op_compiler_respond found unexpected existing compiler output",
);
Ok(json!({}))
});
}