authorgravatar for 11367844+lino-levan@users.noreply.github.comLino Le Van <11367844+lino-levan@users.noreply.github.com> 2024-01-19 10:56:37-08:00
committergravatar for 11367844+lino-levan@users.noreply.github.comLino Le Van <11367844+lino-levan@users.noreply.github.com> 2024-01-19 10:56:37-08:00
logb948c0d8067250014cfa286538e49c419d0acb93
treeac57d63257dc545a02a71d116739f083f997ab51
parent5ddd8626d5574e875e370c53f952a4f087df92b6

chore: rename runtime to target


2 files changed, 16 insertions(+), 6 deletions(-)

crates/cli/src/main.rs+9-6
...@@ -26,12 +26,15 @@ enum Commands {...@@ -26,12 +26,15 @@ enum Commands {
26 // Whether to output to stdout instead of a file26 // Whether to output to stdout instead of a file
27 #[arg(long, default_value_t = false)]27 #[arg(long, default_value_t = false)]
28 stdout: bool,28 stdout: bool,
29 /// What javascript runtime to compile to
30 #[arg(short, long, default_value = "deno")]
31 target: String,
29 },32 },
30 Run {33 Run {
31 file: PathBuf,34 file: PathBuf,
32 /// What javascript runtime to use35 /// What javascript runtime to compile to and use
33 #[arg(short, long, default_value = "deno")]36 #[arg(short, long, default_value = "deno")]
34 runtime: String,37 target: String,
35 },38 },
36}39}
3740
...@@ -63,7 +66,7 @@ fn main() -> Result<()> {...@@ -63,7 +66,7 @@ fn main() -> Result<()> {
63 let cli = Cli::parse();66 let cli = Cli::parse();
6467
65 match cli.command {68 match cli.command {
66 Commands::Compile { file, stdout } => {69 Commands::Compile { file, stdout, target: _ } => {
67 let contents = std::fs::read_to_string(file.clone()).unwrap();70 let contents = std::fs::read_to_string(file.clone()).unwrap();
68 let result = transpile(contents.clone())?;71 let result = transpile(contents.clone())?;
6972
...@@ -73,14 +76,14 @@ fn main() -> Result<()> {...@@ -73,14 +76,14 @@ fn main() -> Result<()> {
73 std::fs::write(file.with_extension("js"), result).unwrap();76 std::fs::write(file.with_extension("js"), result).unwrap();
74 }77 }
75 }78 }
76 Commands::Run { file, runtime } => {79 Commands::Run { file, target } => {
77 let contents = std::fs::read_to_string(file.clone()).unwrap();80 let contents = std::fs::read_to_string(file.clone()).unwrap();
78 let result = transpile(contents.clone())?;81 let result = transpile(contents.clone())?;
79 let mut temp_file = std::env::temp_dir();82 let mut temp_file = std::env::temp_dir();
80 temp_file.push("temp.js");83 temp_file.push("temp.js");
81 std::fs::write(temp_file.clone(), result).unwrap();84 std::fs::write(temp_file.clone(), result).unwrap();
8285
83 let rt = get_runtime(&runtime);86 let rt = get_runtime(&target);
8487
85 match rt.as_str() {88 match rt.as_str() {
86 "deno" => {89 "deno" => {
...@@ -108,7 +111,7 @@ fn main() -> Result<()> {...@@ -108,7 +111,7 @@ fn main() -> Result<()> {
108 println!("{}", String::from_utf8_lossy(&output.stdout));111 println!("{}", String::from_utf8_lossy(&output.stdout));
109 }112 }
110 _ => {113 _ => {
111 println!("Unknown runtime: {}", runtime);114 println!("Unknown runtime: {}", target);
112 }115 }
113 }116 }
114 }117 }
examples/interop/deno.blight created+7
...@@ -0,0 +1,7 @@
1let writeTextFile: any = @raw("Deno.writeTextFile");
2
3fn x() -> string {
4 "hello"
5}
6
7writeTextFile("hello.txt", x());