nopt
nopt copied to clipboard
[BUG] nopt breaks on arguments passed in as numbers
Please consider this minimal example:
node << _EOT_
var nopt = require("nopt")
, parsed = nopt( {}, {}, [ 123 ], 0 )
;
_EOT_
Output:
... /node_modules/nopt/lib/nopt.js:239
if (arg.match(/^-{2,}$/)) {
^
TypeError: Object 123 has no method 'match'
at parse ( ... /node_modules/nopt/lib/nopt.js:239:13)
at nopt ( ... /node_modules/nopt/lib/nopt.js:40:3)
Contrived as this may seem, in the wild I found that yeoman-generator actually does this.
I have made a little change to my local version of nopt that is working as a band aid for this with yeoman at the moment, and that was changing line 237 to var arg = args[i].toString(). This is in no means a permanent fix, but for the replacement of arguments when calling a yo command it seems to be working for me.