| author | |
| committer | |
| log | 2eda3347b628b1f902b618ffff36a81675c91fed |
| tree | 6928768f13ca0b9fd2ff09fe9d9f69ae67d13595 |
| parent | e909581f4c8edf90471d89f9cce5abd05a457a46 |
4 files changed, 20 insertions(+), 4 deletions(-)
cli/src/main.rs+17-1| ... | @@ -33,6 +33,19 @@ enum Commands { | ... | @@ -33,6 +33,19 @@ enum Commands { |
| 33 | }, | 33 | }, |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | fn 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 | |||
| 36 | fn main() -> Result<()> { | 49 | fn main() -> Result<()> { |
| 37 | let cli = Cli::parse(); | 50 | let cli = Cli::parse(); |
| 38 | 51 | ||
| ... | @@ -53,7 +66,10 @@ fn main() -> Result<()> { | ... | @@ -53,7 +66,10 @@ fn main() -> Result<()> { |
| 53 | let mut temp_file = std::env::temp_dir(); | 66 | let mut temp_file = std::env::temp_dir(); |
| 54 | temp_file.push("temp.js"); | 67 | temp_file.push("temp.js"); |
| 55 | std::fs::write(temp_file.clone(), result).unwrap(); | 68 | 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() { | ||
| 57 | "deno" => { | 73 | "deno" => { |
| 58 | let output = std::process::Command::new("deno") | 74 | let output = std::process::Command::new("deno") |
| 59 | .arg("run") | 75 | .arg("run") |
compiler/src/ast/mod.rs+1-1| ... | @@ -306,7 +306,7 @@ fn parse_statement(tokens: &mut ParserContext) -> Result<Ast> { | ... | @@ -306,7 +306,7 @@ fn parse_statement(tokens: &mut ParserContext) -> Result<Ast> { |
| 306 | name, | 306 | name, |
| 307 | arguments, | 307 | arguments, |
| 308 | return_type, | 308 | return_type, |
| 309 | block | 309 | block, |
| 310 | }); | 310 | }); |
| 311 | } | 311 | } |
| 312 | Token::Identifier(name) => match tokens.peek() { | 312 | Token::Identifier(name) => match tokens.peek() { |
compiler/src/ast/types.rs+1-1| ... | @@ -85,7 +85,7 @@ pub enum Ast { | ... | @@ -85,7 +85,7 @@ pub enum Ast { |
| 85 | name: String, | 85 | name: String, |
| 86 | arguments: Vec<Argument>, | 86 | arguments: Vec<Argument>, |
| 87 | return_type: Type, | 87 | return_type: Type, |
| 88 | block: Block | 88 | block: Block, |
| 89 | }, | 89 | }, |
| 90 | FunctionCall { | 90 | FunctionCall { |
| 91 | name: String, | 91 | name: String, |
compiler/src/walker.rs+1-1| ... | @@ -42,7 +42,7 @@ fn transpile_helper(tree: &Ast) -> Result<String> { | ... | @@ -42,7 +42,7 @@ fn transpile_helper(tree: &Ast) -> Result<String> { |
| 42 | name, | 42 | name, |
| 43 | arguments, | 43 | arguments, |
| 44 | return_type: _, | 44 | return_type: _, |
| 45 | block | 45 | block, |
| 46 | } => { | 46 | } => { |
| 47 | let mut result = format!("function {}(", name); | 47 | let mut result = format!("function {}(", name); |
| 48 | 48 |