2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2019-08-14 11:03:02 -04:00
|
|
|
|
2021-12-29 08:30:08 -05:00
|
|
|
use crate::proc_state::ProcState;
|
2022-09-28 13:04:16 -04:00
|
|
|
use deno_core::error::AnyError;
|
|
|
|
use deno_core::op;
|
2021-12-29 08:30:08 -05:00
|
|
|
use deno_core::Extension;
|
2022-09-28 13:04:16 -04:00
|
|
|
use deno_core::OpState;
|
2021-12-29 08:30:08 -05:00
|
|
|
|
2022-03-11 17:07:02 -05:00
|
|
|
pub mod bench;
|
2021-04-28 14:17:04 -04:00
|
|
|
pub mod testing;
|
2020-09-10 09:57:45 -04:00
|
|
|
|
2022-05-17 13:50:31 -04:00
|
|
|
pub fn cli_exts(ps: ProcState) -> Vec<Extension> {
|
2023-03-17 14:22:15 -04:00
|
|
|
vec![deno_cli::init_ops(ps)]
|
2021-12-29 08:30:08 -05:00
|
|
|
}
|
|
|
|
|
2023-03-17 14:22:15 -04:00
|
|
|
deno_core::extension!(deno_cli,
|
|
|
|
ops = [op_npm_process_state],
|
2023-03-17 18:15:27 -04:00
|
|
|
options = {
|
2023-03-17 14:22:15 -04:00
|
|
|
ps: ProcState,
|
|
|
|
},
|
2023-03-17 18:15:27 -04:00
|
|
|
state = |state, options| {
|
|
|
|
state.put(options.ps);
|
2023-03-17 14:22:15 -04:00
|
|
|
},
|
2023-03-18 18:30:04 -04:00
|
|
|
customizer = |ext: &mut deno_core::ExtensionBuilder| {
|
|
|
|
ext.force_op_registration();
|
|
|
|
},
|
2023-03-17 14:22:15 -04:00
|
|
|
);
|
2022-09-28 13:04:16 -04:00
|
|
|
|
|
|
|
#[op]
|
|
|
|
fn op_npm_process_state(state: &mut OpState) -> Result<String, AnyError> {
|
|
|
|
let proc_state = state.borrow_mut::<ProcState>();
|
|
|
|
Ok(proc_state.npm_resolver.get_npm_process_state())
|
|
|
|
}
|