tl;dr: this is how you reliably get arguments across a variety of running modes:
(defn get-args [argv]
(not-empty (js->clj (.slice argv
(if
(.endsWith
(or (aget argv 1) "")
"node_modules/nbb/cli.js")
3 2)))))
version
v1.3.195
platform
Linux: Ubuntu
Node: v20.17.0
problem
You can use *command-line-args* to get args in a .cljs script, but if you then invoke that cljs script from JavaScript the args are nil.
repro
(ns args)
(print *command-line-args*)
import { loadFile } from "nbb";
await loadFile("args.cljs");
Running these:
$ npx nbb args.cljs --hello
(--hello)
$ node args.mjs --hello
nil
expected behavior
I think I would expect the output of the second command to match the first.
tl;dr: this is how you reliably get arguments across a variety of running modes:
version
v1.3.195
platform
Linux: Ubuntu
Node: v20.17.0
problem
You can use
*command-line-args*to get args in a .cljs script, but if you then invoke that cljs script from JavaScript the args are nil.repro
Running these:
expected behavior
I think I would expect the output of the second command to match the first.