The errors thrown by neodoc npm module cause issues for ClojureScript (but not node).
$ java -cp cljs.jar cljs.main --repl-env node
ClojureScript 1.10.758
cljs.user=> (def neodoc (js/require "neodoc"))
#'cljs.user/neodoc
cljs.user=> (.run neodoc "Usage:\n foo" (clj->js {:argv []}))
#js {}
cljs.user=> (.run neodoc "Usage:\n foo" (clj->js {:argv ["bar"] :dontExit true}))
Execution error () at (<cljs repl>:1).
null
cljs.user=> (try (.run neodoc "Usage:\n foo" (clj->js {:argv ["bar"] :dontExit true})) (catch :default e (prn :e e)))
Execution error (TypeError) at (<cljs repl>:1).
Function.prototype.toString requires that 'this' be a Function
This works in node (albeit the thrown object is strange):
Welcome to Node.js v16.13.2.
Type ".help" for more information.
> neodoc = require("neodoc")
{
run: [Function: run],
parse: [Function: parse],
default: { run: [Function: run], parse: [Function: parse] }
}
> neodoc.run("Usage:\n foo", {argv: ["bar"], dontExit: true})
Uncaught:
Function {
message: 'foo: unknown command bar\n' +
'Usage:\n' +
' foo\n' +
'See foo -h/--help for more information',
payload: {}
}
> try { neodoc.run("Usage:\n foo", {argv: ["bar"], dontExit: true}) } catch (e) { console.log("e:", e) }
e: Function {
message: 'foo: unknown command bar\n' +
'Usage:\n' +
' foo\n' +
'See foo -h/--help for more information',
payload: {}
}
undefined