1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00
denoland-deno/cli/ops/mod.rs
Bartek Iwańczuk 8d5c0112fb
feat: don't require --unstable flag for npm programs (#16520)
This PR adds copies of several unstable APIs that are available
in "Deno[Deno.internal].nodeUnstable" namespace.

These copies do not perform unstable check (ie. don't require
"--unstable" flag to be present). Otherwise they work exactly
the same, including permission checks.

These APIs are not meant to be used by users directly and
can change at any time.

Copies of following APIs are available in that namespace:
- Deno.spawnChild
- Deno.spawn
- Deno.spawnSync
- Deno.serve
- Deno.upgradeHttpRaw
- Deno.listenDatagram
2022-11-10 22:03:28 +01:00

30 lines
724 B
Rust

// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
use crate::proc_state::ProcState;
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::Extension;
use deno_core::OpState;
pub mod bench;
pub mod testing;
pub fn cli_exts(ps: ProcState) -> Vec<Extension> {
vec![init_proc_state(ps)]
}
fn init_proc_state(ps: ProcState) -> Extension {
Extension::builder()
.ops(vec![op_npm_process_state::decl()])
.state(move |state| {
state.put(ps.clone());
Ok(())
})
.build()
}
#[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())
}