@@ -86,7 +86,7 @@ Option.prototype.attributeName = function() {
8686 */
8787
8888Option . prototype . is = function ( arg ) {
89- return arg == this . short || arg == this . long ;
89+ return this . short === arg || this . long === arg ;
9090} ;
9191
9292/**
@@ -377,7 +377,7 @@ Command.prototype.option = function(flags, description, fn, defaultValue) {
377377 name = option . attributeName ( ) ;
378378
379379 // default as 3rd arg
380- if ( typeof fn != 'function' ) {
380+ if ( typeof fn !== 'function' ) {
381381 if ( fn instanceof RegExp ) {
382382 var regex = fn ;
383383 fn = function ( val , def ) {
@@ -391,11 +391,11 @@ Command.prototype.option = function(flags, description, fn, defaultValue) {
391391 }
392392
393393 // preassign default value only for --no-*, [optional], or <required>
394- if ( option . bool == false || option . optional || option . required ) {
394+ if ( ! option . bool || option . optional || option . required ) {
395395 // when --no-* we make sure default is true
396- if ( option . bool == false ) defaultValue = true ;
396+ if ( ! option . bool ) defaultValue = true ;
397397 // preassign only if we have a default
398- if ( undefined !== defaultValue ) {
398+ if ( defaultValue !== undefined ) {
399399 self [ name ] = defaultValue ;
400400 option . defaultValue = defaultValue ;
401401 }
@@ -484,7 +484,7 @@ Command.prototype.parse = function(argv) {
484484 } ) [ 0 ] ;
485485 }
486486
487- if ( this . _execs [ name ] && typeof this . _execs [ name ] != 'function' ) {
487+ if ( this . _execs [ name ] && typeof this . _execs [ name ] !== 'function' ) {
488488 return this . executeSubCommand ( argv , args , parsed . unknown ) ;
489489 } else if ( aliasCommand ) {
490490 // is alias of a subCommand
@@ -512,10 +512,10 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
512512 args = args . concat ( unknown ) ;
513513
514514 if ( ! args . length ) this . help ( ) ;
515- if ( args [ 0 ] == 'help' && args . length === 1 ) this . help ( ) ;
515+ if ( args [ 0 ] === 'help' && args . length === 1 ) this . help ( ) ;
516516
517517 // <cmd> --help
518- if ( args [ 0 ] == 'help' ) {
518+ if ( args [ 0 ] === 'help' ) {
519519 args [ 0 ] = args [ 1 ] ;
520520 args [ 1 ] = '--help' ;
521521 }
@@ -576,9 +576,9 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
576576 } ) ;
577577 proc . on ( 'close' , process . exit . bind ( process ) ) ;
578578 proc . on ( 'error' , function ( err ) {
579- if ( err . code == 'ENOENT' ) {
579+ if ( err . code === 'ENOENT' ) {
580580 console . error ( '\n %s(1) does not exist, try --help\n' , bin ) ;
581- } else if ( err . code == 'EACCES' ) {
581+ } else if ( err . code === 'EACCES' ) {
582582 console . error ( '\n %s(1) not executable. try chmod or run with root\n' , bin ) ;
583583 }
584584 process . exit ( 1 ) ;
@@ -616,7 +616,7 @@ Command.prototype.normalize = function(args) {
616616 break ;
617617 } else if ( lastOpt && lastOpt . required ) {
618618 ret . push ( arg ) ;
619- } else if ( arg . length > 1 && arg [ 0 ] == '-' && arg [ 1 ] != '-' ) {
619+ } else if ( arg . length > 1 && arg [ 0 ] === '-' && arg [ 1 ] != = '-' ) {
620620 arg . slice ( 1 ) . split ( '' ) . forEach ( function ( c ) {
621621 ret . push ( '-' + c ) ;
622622 } ) ;
@@ -709,7 +709,7 @@ Command.prototype.parseOptions = function(argv) {
709709 continue ;
710710 }
711711
712- if ( arg == '--' ) {
712+ if ( arg === '--' ) {
713713 literal = true ;
714714 continue ;
715715 }
@@ -727,7 +727,7 @@ Command.prototype.parseOptions = function(argv) {
727727 // optional arg
728728 } else if ( option . optional ) {
729729 arg = argv [ i + 1 ] ;
730- if ( arg == null || ( arg [ 0 ] == '-' && arg != '-' ) ) {
730+ if ( arg == null || ( arg [ 0 ] === '-' && arg != = '-' ) ) {
731731 arg = null ;
732732 } else {
733733 ++ i ;
@@ -741,13 +741,13 @@ Command.prototype.parseOptions = function(argv) {
741741 }
742742
743743 // looks like an option
744- if ( arg . length > 1 && arg [ 0 ] == '-' ) {
744+ if ( arg . length > 1 && arg [ 0 ] === '-' ) {
745745 unknownOptions . push ( arg ) ;
746746
747747 // If the next argument looks like it might be
748748 // an argument for this option, we pass it on.
749749 // If it isn't, then it'll simply be ignored
750- if ( argv [ i + 1 ] && argv [ i + 1 ] [ 0 ] != '-' ) {
750+ if ( argv [ i + 1 ] && argv [ i + 1 ] [ 0 ] !== '-' ) {
751751 unknownOptions . push ( argv [ ++ i ] ) ;
752752 }
753753 continue ;
@@ -962,7 +962,7 @@ Command.prototype.optionHelp = function() {
962962 // Append the help information
963963 return this . options . map ( function ( option ) {
964964 return pad ( option . flags , width ) + ' ' + option . description +
965- ( ( option . bool != false && option . defaultValue !== undefined ) ? ' (default: ' + option . defaultValue + ')' : '' ) ;
965+ ( ( option . bool && option . defaultValue !== undefined ) ? ' (default: ' + option . defaultValue + ')' : '' ) ;
966966 } ) . concat ( [ pad ( '-h, --help' , width ) + ' ' + 'output usage information' ] )
967967 . join ( '\n' ) ;
968968} ;
@@ -1120,7 +1120,7 @@ function pad(str, width) {
11201120function outputHelpIfNecessary ( cmd , options ) {
11211121 options = options || [ ] ;
11221122 for ( var i = 0 ; i < options . length ; i ++ ) {
1123- if ( options [ i ] == '--help' || options [ i ] == '-h' ) {
1123+ if ( options [ i ] === '--help' || options [ i ] = == '-h' ) {
11241124 cmd . outputHelp ( ) ;
11251125 process . exit ( 0 ) ;
11261126 }
0 commit comments