diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-10-01 20:33:15 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 20:33:15 +1000 |
commit | e077b93d77d42f805ceb7a58cdc3c42255c0a30b (patch) | |
tree | f9b2f9c3826d43438028fa4b74c7846b352062a2 /cli/tsc.rs | |
parent | ef5ae4547a4eb0a2fc2309a9dac934275b86ae82 (diff) |
refactor: add concept of 'legacy' compiler to enable non-breaking refactoring (#7762)
Diffstat (limited to 'cli/tsc.rs')
-rw-r--r-- | cli/tsc.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cli/tsc.rs b/cli/tsc.rs index 9b944125f..f1e49167a 100644 --- a/cli/tsc.rs +++ b/cli/tsc.rs @@ -942,6 +942,11 @@ impl TsCompiler { } } +#[derive(Debug, Deserialize)] +struct CreateHashArgs { + data: String, +} + fn execute_in_tsc( global_state: Arc<GlobalState>, req: String, @@ -975,6 +980,14 @@ fn execute_in_tsc( Ok(json!({})) }), ); + js_runtime.register_op( + "op_create_hash", + json_op_sync(move |_s, args, _bufs| { + let v: CreateHashArgs = serde_json::from_value(args)?; + let hash = crate::checksum::gen(&[v.data.as_bytes()]); + Ok(json!({ "hash": hash })) + }), + ); } let bootstrap_script = format!( |