deno script args spread to array (#203)

smol issue where a deno script with parameters named `main` or `run`
will try to assign over imported main or the run function.

This uses the spread syntax to unpack the arguments and arrange them in
an array in argument order.  Instead of making assignments to the scope.
This commit is contained in:
sqwishy
2022-07-14 21:30:31 +02:00
committed by GitHub
parent 3a25ed24ce
commit af9dec7bf4
+5 -2
View File
@@ -604,10 +604,13 @@ print(res_json)
let wrapper_content: String = format!(
r#"
import {{ main }} from "./inner.ts";
const {{{spread}}} = JSON.parse(await Deno.readTextFile("args.json"))
const args = await Deno.readTextFile("args.json")
.then(JSON.parse)
.then(({{ {spread} }}) => [ {spread} ])
async function run() {{
let res: any = await main({spread});
let res: any = await main(...args);
if (res == undefined) {{
res = {{}}
}}