Skip to content

Commit

Permalink
Fix: Change max-warnings type to Int (fixes #4660)
Browse files Browse the repository at this point in the history
Updated Optionator to version 0.8.0
Changed the type of the --max-warnings flag from 'Number' to 'Int'
An error will now be displayed if a non-integer value is supplied
  • Loading branch information
gkz committed Dec 29, 2015
1 parent e8939e4 commit 315f272
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/user-guide/command-line-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Using stdin:
Handling warnings:
--quiet Report errors only - default: false
--max-warnings Number Number of warnings to trigger nonzero exit code -
--max-warnings Int Number of warnings to trigger nonzero exit code -
default: -1
Output:
Expand Down
2 changes: 1 addition & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module.exports = optionator({
},
{
option: "max-warnings",
type: "Number",
type: "Int",
default: "-1",
description: "Number of warnings to trigger nonzero exit code"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"minimatch": "^3.0.0",
"mkdirp": "^0.5.0",
"object-assign": "^4.0.1",
"optionator": "^0.7.1",
"optionator": "^0.8.0",
"path-is-absolute": "^1.0.0",
"path-is-inside": "^1.0.1",
"shelljs": "^0.5.3",
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ describe("options", function() {
var currentOptions = options.parse("");
assert.equal(currentOptions.maxWarnings, -1);
});

it("should throw an error when supplied with a non-integer", function() {
assert.throws(function() {
options.parse("--max-warnings 10.2");
}, /Invalid value for option 'max-warnings' - expected type Int/);
});
});

describe("--init", function() {
Expand Down

0 comments on commit 315f272

Please sign in to comment.