diff --git a/cli/src/cmd/mod.rs b/cli/src/cmd/mod.rs index 3045870c53..386fc9ed2f 100644 --- a/cli/src/cmd/mod.rs +++ b/cli/src/cmd/mod.rs @@ -1,5 +1,6 @@ pub mod community; pub mod repl; +pub mod run; pub mod scan; pub mod start; pub mod webui; diff --git a/cli/src/cmd/repl.rs b/cli/src/cmd/repl.rs index 4e9d90b2c6..90882e022b 100644 --- a/cli/src/cmd/repl.rs +++ b/cli/src/cmd/repl.rs @@ -5,8 +5,9 @@ macro_rules! svec { } pub fn repl() { - let handle = thread::spawn(|| { - deno::cli(svec!["deno", "repl", "-A"]); + let handle = thread::spawn(|| match deno::cli(svec!["deno", "repl", "-A"]) { + Ok(_) => {} + Err(_) => {} }); handle.join().unwrap(); } diff --git a/cli/src/cmd/run.rs b/cli/src/cmd/run.rs new file mode 100644 index 0000000000..a16a1bcc73 --- /dev/null +++ b/cli/src/cmd/run.rs @@ -0,0 +1,9 @@ +use std::{ffi::OsString, thread}; + +pub fn run(args: Vec) { + let handle = thread::spawn(move || match deno::cli(args) { + Ok(_) => {} + Err(_) => {} + }); + handle.join().unwrap(); +} diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 489daab419..c91a4fca0c 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -27,9 +27,8 @@ pub fn install_rockboxd() -> Result<(), Error> { } pub fn wait_for_rockboxd(port: u32, timeout: Option) -> Result<(), Error> { - setup_pkgx()?; let cmd = format!( - "pkgx deno run -A npm:wait-port localhost:{} -t {}", + "rockbox run -A npm:wait-port localhost:{} -t {}", port, timeout.unwrap_or(60) * 1000 ); diff --git a/cli/src/main.rs b/cli/src/main.rs index a38fe0657a..4e62dcb59a 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,8 +1,10 @@ +use std::ffi::OsString; + use anyhow::Error; use clap::{arg, Command}; use owo_colors::OwoColorize; -use cmd::{community::*, repl::*, scan::*, start::*, webui::*}; +use cmd::{community::*, repl::*, run::*, scan::*, start::*, webui::*}; pub mod cmd; @@ -46,10 +48,30 @@ fn cli() -> Command { .about("Start the Rockbox REPL") .visible_alias("shell"), ) + .subcommand( + Command::new("run") + .arg(arg!( "JavaScript or TypeScript file to run")) + .about("Run a JavaScript or TypeScript program") + .visible_alias("x"), + ) } #[tokio::main] async fn main() -> Result<(), Error> { + let args = std::env::args().collect::>(); + if args.len() > 1 && args[1] == "run" { + let _args = args + .into_iter() + .map(|s| match s.as_str() { + "rockbox" => "deno".into(), + _ => s.into(), + }) + .collect::>(); + + run(_args); + return Ok(()); + } + let matches = cli().get_matches(); match matches.subcommand() { diff --git a/crates/mpd/src/handlers/system.rs b/crates/mpd/src/handlers/system.rs index c4f86ad332..c29863479b 100644 --- a/crates/mpd/src/handlers/system.rs +++ b/crates/mpd/src/handlers/system.rs @@ -1,5 +1,3 @@ -use std::os::unix::thread; - use anyhow::Error; use tokio::sync::mpsc::Sender; diff --git a/deno b/deno index 53a51bd19f..287e34d4cb 160000 --- a/deno +++ b/deno @@ -1 +1 @@ -Subproject commit 53a51bd19fc1ba31b66e3249badb32a8c6fb4c6c +Subproject commit 287e34d4cb14989ec37c98cd30fd60e04bb683a8