Skip to content

Commit 6867a34

Browse files
Fix validation of -- options
The validation of -- options passed on the command line depends on yargs module. Update it to latest versions as the previously used one didn't set correct values of options marked as strings. Also in our code we pass object of valid options to yargs. Options which have `-` in the name are treated in a special manner in yargs. However instead of passing them with `-`, we pass their secondary representation (remove the `-` and capitalize the next letter). This way, when the user passes option with `-`, yargs treat it with it's default behavior and does not respect our options for it (as we have not defined that we have option with `-`). Example: ```JavaScript var yargs = require("yargs"); var opts = { "profile-dir": { type: "string" } }; console.log(yargs(process.argv).options(opts).argv); var opts1 = { "profileDir": { type: "string" } }; console.log(yargs(process.argv).options(opts1).argv); ``` When called with: ``` node testYargs.js --profile-dir ``` The result is: ``` { 'profile-dir': '', profileDir: '', '$0': 'testYargs.js' } { 'profile-dir': true, profileDir: true, '$0': 'testYargs.js' } ``` As you can see, passing "profileDir" and defining it as string does not work. But when we use "profile-dir" in our opts, everything works as expected and yargs sets the value to empty string. In order to resolve the problem, make sure we pass options with dashes to yargs. When boolean value is passed to isNullOrWhitespace helper method, it fails as true.replace is not available function. Add unit tests for: - options issue - assert correct behavior when dashed option is passed on the terminal - helpers isNullOrWhitespace method - helpers isBoolean method
1 parent c67898c commit 6867a34

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"xcode": "https://github.com/NativeScript/node-xcode/archive/1.4.0.tar.gz",
7979
"xmldom": "0.1.21",
8080
"xmlhttprequest": "https://github.com/telerik/node-XMLHttpRequest/tarball/master",
81-
"yargs": "3.15.0"
81+
"yargs": "6.0.0"
8282
},
8383
"analyze": true,
8484
"devDependencies": {

0 commit comments

Comments
 (0)