All files / src/cli-validator/utils modified-commander.js

90.91% Statements 10/11
50% Branches 1/2
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x             1x     1x 1x 1x 1x 1x     1x   1x     1x  
const program = require('commander');
 
// This module is used to modify the commander code. When
// an unsupported option is given, only a single-line error
// is printed. Now, it will also print out the usage menu.
 
// deletes the function in order to reimplement it
delete program['unknownOption'];
 
// reimplementing the funciton
program.unknownOption = function(flag) {
  Iif (this._allowUnknownOption) return;
  console.error();
  console.error("  error: unknown option `%s'", flag);
  console.error();
 
  // this is the extra code added to the function
  this.outputHelp();
 
  process.exit(1);
};
 
module.exports = program;