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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::cmd::run_cmd_directly;
use crate::errors::*;
use crate::parse::{SnoopServeOpts, SnoopWasmOpts};
use std::env;
use std::path::PathBuf;
pub fn snoop_build(dir: PathBuf) -> Result<i32, ExecutionError> {
let target = dir.join(".perseus/builder");
run_cmd_directly(
format!(
"{} run",
env::var("PERSEUS_CARGO_PATH").unwrap_or_else(|_| "cargo".to_string())
),
&target,
)
}
pub fn snoop_wasm_build(dir: PathBuf, opts: SnoopWasmOpts) -> Result<i32, ExecutionError> {
let target = dir.join(".perseus");
run_cmd_directly(
format!(
"{} build --target web {}",
env::var("PERSEUS_WASM_PACK_PATH").unwrap_or_else(|_| "wasm-pack".to_string()),
if opts.profiling {
"--profiling"
} else {
"--dev"
}
),
&target,
)
}
pub fn snoop_server(dir: PathBuf, opts: SnoopServeOpts) -> Result<i32, ExecutionError> {
env::set_var("PERSEUS_HOST", opts.host);
env::set_var("PERSEUS_PORT", opts.port.to_string());
let target = dir.join(".perseus/server");
run_cmd_directly(
format!(
"{} run --features integration-{} --no-default-features",
env::var("PERSEUS_CARGO_PATH").unwrap_or_else(|_| "cargo".to_string()),
opts.integration.to_string()
),
&target,
)
}