@@ -523,7 +523,7 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
523523 // executable
524524 var f = argv [ 1 ] ;
525525 // name of the subcommand, link `pm-install`
526- var bin = basename ( f , '.js' ) + '-' + args [ 0 ] ;
526+ var bin = basename ( f , path . extname ( f ) ) + '-' + args [ 0 ] ;
527527
528528 // In case of globally installed, get the base dir where executable
529529 // subcommand file should be located at
@@ -539,11 +539,14 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
539539 // prefer local `./<bin>` to bin in the $PATH
540540 var localBin = path . join ( baseDir , bin ) ;
541541
542- // whether bin file is a js script with explicit `.js` extension
542+ // whether bin file is a js script with explicit `.js` or `.ts` extension
543543 var isExplicitJS = false ;
544544 if ( exists ( localBin + '.js' ) ) {
545545 bin = localBin + '.js' ;
546546 isExplicitJS = true ;
547+ } else if ( exists ( localBin + '.ts' ) ) {
548+ bin = localBin + '.ts' ;
549+ isExplicitJS = true ;
547550 } else if ( exists ( localBin ) ) {
548551 bin = localBin ;
549552 }
@@ -577,9 +580,9 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
577580 proc . on ( 'close' , process . exit . bind ( process ) ) ;
578581 proc . on ( 'error' , function ( err ) {
579582 if ( err . code === 'ENOENT' ) {
580- console . error ( '\n %s(1) does not exist, try --help\n ' , bin ) ;
583+ console . error ( '%s(1) does not exist, try --help' , bin ) ;
581584 } else if ( err . code === 'EACCES' ) {
582- console . error ( '\n %s(1) not executable. try chmod or run with root\n ' , bin ) ;
585+ console . error ( '%s(1) not executable. try chmod or run with root' , bin ) ;
583586 }
584587 process . exit ( 1 ) ;
585588 } ) ;
@@ -1069,12 +1072,12 @@ Command.prototype.commandHelp = function() {
10691072 var width = this . padWidth ( ) ;
10701073
10711074 return [
1072- ' Commands:' ,
1075+ 'Commands:' ,
10731076 '' ,
10741077 commands . map ( function ( cmd ) {
10751078 var desc = cmd [ 1 ] ? ' ' + cmd [ 1 ] : '' ;
10761079 return ( desc ? pad ( cmd [ 0 ] , width ) : cmd [ 0 ] ) + desc ;
1077- } ) . join ( '\n' ) . replace ( / ^ / gm, ' ' ) ,
1080+ } ) . join ( '\n' ) . replace ( / ^ / gm, ' ' ) ,
10781081 ''
10791082 ] . join ( '\n' ) ;
10801083} ;
@@ -1090,17 +1093,17 @@ Command.prototype.helpInformation = function() {
10901093 var desc = [ ] ;
10911094 if ( this . _description ) {
10921095 desc = [
1093- ' ' + this . _description ,
1096+ this . _description ,
10941097 ''
10951098 ] ;
10961099
10971100 var argsDescription = this . _argsDescription ;
10981101 if ( argsDescription && this . _args . length ) {
10991102 var width = this . padWidth ( ) ;
1100- desc . push ( ' Arguments:' ) ;
1103+ desc . push ( 'Arguments:' ) ;
11011104 desc . push ( '' ) ;
11021105 this . _args . forEach ( function ( arg ) {
1103- desc . push ( ' ' + pad ( arg . name , width ) + ' ' + argsDescription [ arg . name ] ) ;
1106+ desc . push ( ' ' + pad ( arg . name , width ) + ' ' + argsDescription [ arg . name ] ) ;
11041107 } ) ;
11051108 desc . push ( '' ) ;
11061109 }
@@ -1111,8 +1114,7 @@ Command.prototype.helpInformation = function() {
11111114 cmdName = cmdName + '|' + this . _alias ;
11121115 }
11131116 var usage = [
1114- '' ,
1115- ' Usage: ' + cmdName + ' ' + this . usage ( ) ,
1117+ 'Usage: ' + cmdName + ' ' + this . usage ( ) ,
11161118 ''
11171119 ] ;
11181120
@@ -1121,17 +1123,16 @@ Command.prototype.helpInformation = function() {
11211123 if ( commandHelp ) cmds = [ commandHelp ] ;
11221124
11231125 var options = [
1124- ' Options:' ,
1126+ 'Options:' ,
11251127 '' ,
1126- '' + this . optionHelp ( ) . replace ( / ^ / gm, ' ' ) ,
1128+ '' + this . optionHelp ( ) . replace ( / ^ / gm, ' ' ) ,
11271129 ''
11281130 ] ;
11291131
11301132 return usage
11311133 . concat ( desc )
11321134 . concat ( options )
11331135 . concat ( cmds )
1134- . concat ( [ '' ] )
11351136 . join ( '\n' ) ;
11361137} ;
11371138
0 commit comments