Skip to content

Commit

Permalink
removed newline above and below errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpetersen authored and roman-vanesyan committed Oct 1, 2018
1 parent b6549f2 commit 6c0c1f6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
8 changes: 0 additions & 8 deletions index.js
Expand Up @@ -792,9 +792,7 @@ Command.prototype.opts = function() {
*/

Command.prototype.missingArgument = function(name) {
console.error();
console.error("error: missing required argument `%s'", name);
console.error();
process.exit(1);
};

Expand All @@ -807,13 +805,11 @@ Command.prototype.missingArgument = function(name) {
*/

Command.prototype.optionMissingArgument = function(option, flag) {
console.error();
if (flag) {
console.error("error: option `%s' argument missing, got `%s'", option.flags, flag);
} else {
console.error("error: option `%s' argument missing", option.flags);
}
console.error();
process.exit(1);
};

Expand All @@ -826,9 +822,7 @@ Command.prototype.optionMissingArgument = function(option, flag) {

Command.prototype.unknownOption = function(flag) {
if (this._allowUnknownOption) return;
console.error();
console.error("error: unknown option `%s'", flag);
console.error();
process.exit(1);
};

Expand All @@ -840,9 +834,7 @@ Command.prototype.unknownOption = function(flag) {
*/

Command.prototype.variadicArgNotLast = function(name) {
console.error();
console.error("error: variadic arguments must be last `%s'", name);
console.error();
process.exit(1);
};

Expand Down
4 changes: 2 additions & 2 deletions test/test.command.allowUnknownOption.js
Expand Up @@ -13,7 +13,7 @@ program
.option('-p, --pepper', 'add pepper');
program.parse('node test -m'.split(' '));

stubError.callCount.should.equal(3);
stubError.callCount.should.equal(1);


// test subcommand
Expand All @@ -24,7 +24,7 @@ program
});
program.parse('node test sub -m'.split(' '));

stubError.callCount.should.equal(3);
stubError.callCount.should.equal(1);
stubExit.calledOnce.should.be.true();

// command with `allowUnknownOption`
Expand Down
4 changes: 2 additions & 2 deletions test/test.options.args.required.js
Expand Up @@ -14,8 +14,8 @@ console.error = function () {

process.on('exit', function (code) {
code.should.equal(1);
info.length.should.equal(3);
info[1].should.equal("error: option `-c, --cheese <type>' argument missing");
info.length.should.equal(1);
info[0].should.equal("error: option `-c, --cheese <type>' argument missing");
process.exit(0)
});

Expand Down
6 changes: 1 addition & 5 deletions test/test.variadic.args.js
Expand Up @@ -57,8 +57,4 @@ try {
process.exit = oldProcessExit;
console.error = oldConsoleError;

[
'',
'error: variadic arguments must be last `variadicArg\'',
''
].join('\n').should.eql(errorMessage);
'error: variadic arguments must be last `variadicArg\''.should.eql(errorMessage);

0 comments on commit 6c0c1f6

Please sign in to comment.