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
loga48e3140847de5e8d23909ef8b34f357ed761ed8
treeac57d63257dc545a02a71d116739f083f997ab51
parent22b2489114fdd8227df13c46b75ab939aa8c6aed

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 {
2626 // Whether to output to stdout instead of a file
2727 #[arg(long, default_value_t = false)]
2828 stdout: bool,
29 /// What javascript runtime to compile to
30 #[arg(short, long, default_value = "deno")]
31 target: String,
2932 },
3033 Run {
3134 file: PathBuf,
32 /// What javascript runtime to use
35 /// What javascript runtime to compile to and use
3336 #[arg(short, long, default_value = "deno")]
34 runtime: String,
37 target: String,
3538 },
3639}
3740
......@@ -63,7 +66,7 @@ fn main() -> Result<()> {
6366 let cli = Cli::parse();
6467
6568 match cli.command {
66 Commands::Compile { file, stdout } => {
69 Commands::Compile { file, stdout, target: _ } => {
6770 let contents = std::fs::read_to_string(file.clone()).unwrap();
6871 let result = transpile(contents.clone())?;
6972
......@@ -73,14 +76,14 @@ fn main() -> Result<()> {
7376 std::fs::write(file.with_extension("js"), result).unwrap();
7477 }
7578 }
76 Commands::Run { file, runtime } => {
79 Commands::Run { file, target } => {
7780 let contents = std::fs::read_to_string(file.clone()).unwrap();
7881 let result = transpile(contents.clone())?;
7982 let mut temp_file = std::env::temp_dir();
8083 temp_file.push("temp.js");
8184 std::fs::write(temp_file.clone(), result).unwrap();
8285
83 let rt = get_runtime(&runtime);
86 let rt = get_runtime(&target);
8487
8588 match rt.as_str() {
8689 "deno" => {
......@@ -108,7 +111,7 @@ fn main() -> Result<()> {
108111 println!("{}", String::from_utf8_lossy(&output.stdout));
109112 }
110113 _ => {
111 println!("Unknown runtime: {}", runtime);
114 println!("Unknown runtime: {}", target);
112115 }
113116 }
114117 }
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());