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
|
|
|
|
2023-04-17 15:36:23 -04:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2023-04-21 21:02:46 -04:00
|
|
|
use crate::npm::CliNpmResolver;
|
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
|
|
|
|
2023-04-21 21:02:46 -04:00
|
|
|
pub fn cli_exts(npm_resolver: Arc<CliNpmResolver>) -> Vec<Extension> {
|
2023-06-13 18:36:16 -04:00
|
|
|
vec![deno_cli::init_ops(npm_resolver)]
|
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-04-21 21:02:46 -04:00
|
|
|
npm_resolver: Arc<CliNpmResolver>,
|
2023-03-17 14:22:15 -04:00
|
|
|
},
|
2023-03-17 18:15:27 -04:00
|
|
|
state = |state, options| {
|
2023-04-17 15:36:23 -04:00
|
|
|
state.put(options.npm_resolver);
|
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> {
|
2023-04-21 21:02:46 -04:00
|
|
|
let npm_resolver = state.borrow_mut::<Arc<CliNpmResolver>>();
|
2023-04-17 15:36:23 -04:00
|
|
|
Ok(npm_resolver.get_npm_process_state())
|
2022-09-28 13:04:16 -04:00
|
|
|
}
|