authorgravatar for 11367844+lino-levan@users.noreply.github.comLino Le Van <11367844+lino-levan@users.noreply.github.com> 2024-01-16 13:35:15-08:00
committergravatar for 11367844+lino-levan@users.noreply.github.comLino Le Van <11367844+lino-levan@users.noreply.github.com> 2024-01-16 13:35:15-08:00
log2eda3347b628b1f902b618ffff36a81675c91fed
tree6928768f13ca0b9fd2ff09fe9d9f69ae67d13595
parente909581f4c8edf90471d89f9cce5abd05a457a46

feat: add dave check


4 files changed, 20 insertions(+), 4 deletions(-)

cli/src/main.rs+17-1
......@@ -33,6 +33,19 @@ enum Commands {
3333 },
3434}
3535
36fn get_runtime(runtime: &String) -> String {
37 match std::env::var("USER") {
38 Ok(user) => {
39 if user == "dave" {
40 String::from("bun")
41 } else {
42 runtime.clone()
43 }
44 }
45 _ => runtime.clone(),
46 }
47}
48
3649fn main() -> Result<()> {
3750 let cli = Cli::parse();
3851
......@@ -53,7 +66,10 @@ fn main() -> Result<()> {
5366 let mut temp_file = std::env::temp_dir();
5467 temp_file.push("temp.js");
5568 std::fs::write(temp_file.clone(), result).unwrap();
56 match runtime.as_str() {
69
70 let rt = get_runtime(&runtime);
71
72 match rt.as_str() {
5773 "deno" => {
5874 let output = std::process::Command::new("deno")
5975 .arg("run")
compiler/src/ast/mod.rs+1-1
......@@ -306,7 +306,7 @@ fn parse_statement(tokens: &mut ParserContext) -> Result<Ast> {
306306 name,
307307 arguments,
308308 return_type,
309 block
309 block,
310310 });
311311 }
312312 Token::Identifier(name) => match tokens.peek() {
compiler/src/ast/types.rs+1-1
......@@ -85,7 +85,7 @@ pub enum Ast {
8585 name: String,
8686 arguments: Vec<Argument>,
8787 return_type: Type,
88 block: Block
88 block: Block,
8989 },
9090 FunctionCall {
9191 name: String,
compiler/src/walker.rs+1-1
......@@ -42,7 +42,7 @@ fn transpile_helper(tree: &Ast) -> Result<String> {
4242 name,
4343 arguments,
4444 return_type: _,
45 block
45 block,
4646 } => {
4747 let mut result = format!("function {}(", name);
4848