-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Run this simple script WITHOUT any cli arguments:
const path = require("path");
const yargs = require("yargs/yargs");
const argv = yargs(process.argv.slice(2))
.option("someArg", {
type: "string",
coerce: path.resolve
})
.parse();You will get error message in output:
[C:\Program]() Files\nodejs\node.exe [.\main.js]()
Options:
--help Show help [boolean]
--version Show version number [boolean]
--someArg [string]
node_modules/yargs/build/index.cjs:1
The "path" argument must be of type string. Received undefined
node_modules/yargs/build/index.cjs:1
Process exited with code 1
Does it correct? If my someArg is not a demand, why he "gets" default value undefined and then coerce is called? And, of cource, path.resolve drop this error
I think, it's not correct, to call coerce, if user not give an argument
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels