summaryrefslogtreecommitdiff
path: root/cli/ops/mod.rs
blob: 05f1426ecbd3f201dc8d4a0492b6debdda4652af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

use crate::proc_state::ProcState;
use deno_core::Extension;

pub mod bench;
mod errors;
mod runtime_compiler;
pub mod testing;

pub fn cli_exts(ps: ProcState, enable_compiler: bool) -> Vec<Extension> {
  if enable_compiler {
    vec![
      init_proc_state(ps),
      errors::init(),
      runtime_compiler::init(),
    ]
  } else {
    vec![init_proc_state(ps), errors::init()]
  }
}

fn init_proc_state(ps: ProcState) -> Extension {
  Extension::builder()
    .state(move |state| {
      state.put(ps.clone());
      Ok(())
    })
    .build()
}