You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some possible solutions. Simplest would be to add the "script path" to the processArgs variable, to be "backwards compatible" with node code. Do you want me to PR that, or do you see a better alternative?
Issue Type
Expected
A simple
cac
cli written in node with one command should find the command when called.e.g.
Create a file
cli.ts
with contents:Then run
deno install cli cli.ts
and finallycli install a
Expected behavior: the
console.log
should executeActual
Nothing happens! Because the library cannot find the command given incorrect
argv
handling.If you call it with an extra argument, though it works:
cli whatever install a
Result:
console.log
is called.Possible Solutions
I believe this happened because of this change: denoland/deno#2123 (comment)
Now,
Deno.args
only has the actual arguments.This is the source of the problem:
cac/src/node.ts
Line 6 in aa8f868
In
node
, theargv
process has two "useless" elements in the beginning: thenode
executable itself, and the path to the script which started execution:https://nodejs.org/docs/latest/api/process.html#process_process_argv
And finally, here is where we "remove" those two useless args, but they're not useless for Deno! They are the args.
cac/src/CAC.ts
Line 178 in aa8f868
There are some possible solutions. Simplest would be to add the "script path" to the processArgs variable, to be "backwards compatible" with node code. Do you want me to PR that, or do you see a better alternative?
Thanks for the great lib!
Info
The text was updated successfully, but these errors were encountered: