From c9749d340ec64a124812904f3ac00f63546bbf6d Mon Sep 17 00:00:00 2001 From: tommy-xr Date: Sat, 15 Jun 2024 13:40:18 -0700 Subject: [PATCH] feat(web): Open browser with run wasm (#26) --- cli/src/commands/run.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/run.rs b/cli/src/commands/run.rs index 36f9034..7579d98 100644 --- a/cli/src/commands/run.rs +++ b/cli/src/commands/run.rs @@ -30,6 +30,22 @@ pub async fn execute(working_directory: &str, environment: &Environment) -> Resu }]; util::ShellCommand::run_sequential(commands).await } - Environment::Wasm => WasmDevServer::start(build_wasm_wd.to_str().unwrap()).await, + Environment::Wasm => { + let cmd = if std::env::consts::OS == "windows" { + "start" + } else { + "open" + }; + let wasm_server_start = WasmDevServer::start(build_wasm_wd.to_str().unwrap()); + let commands = vec![ShellCommand { + prefix: "[Open Browser]", + cmd, + cwd: working_directory, + env: vec![], + args: vec!["http://127.0.0.1:8080"], + }]; + util::ShellCommand::run_sequential(commands).await?; + wasm_server_start.await + } } }