commander 2.17.1 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 2.18.0 / 2018-09-07
3
+ ==================
4
+
5
+ * Standardize help output (#853)
6
+ * chmod 644 travis.yml (#851)
7
+ * add support for execute typescript subcommand via ts-node (#849)
8
+
2
9
  2.17.1 / 2018-08-07
3
10
  ==================
4
11
 
package/Readme.md CHANGED
@@ -45,7 +45,7 @@ console.log(' - %s cheese', program.cheese);
45
45
 
46
46
  Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
47
47
 
48
- Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false.
48
+ Note that multi-word options starting with `--no` prefix negate the boolean value of the following word. For example, `--no-sauce` sets the value of `program.sauce` to false.
49
49
 
50
50
  ```js
51
51
  #!/usr/bin/env node
@@ -153,7 +153,7 @@ program
153
153
  .option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
154
154
  .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
155
155
  .parse(process.argv);
156
-
156
+
157
157
  console.log(' size: %j', program.size);
158
158
  console.log(' drink: %j', program.drink);
159
159
  ```
@@ -248,22 +248,20 @@ You can enable `--harmony` option in two ways:
248
248
  The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
249
249
 
250
250
  ```
251
- $ ./examples/pizza --help
252
-
253
- Usage: pizza [options]
251
+ $ ./examples/pizza --help
252
+ Usage: pizza [options]
254
253
 
255
- An application for pizzas ordering
254
+ An application for pizzas ordering
256
255
 
257
- Options:
258
-
259
- -h, --help output usage information
260
- -V, --version output the version number
261
- -p, --peppers Add peppers
262
- -P, --pineapple Add pineapple
263
- -b, --bbq Add bbq sauce
264
- -c, --cheese <type> Add the specified type of cheese [marble]
265
- -C, --no-cheese You do not want any cheese
256
+ Options:
266
257
 
258
+ -h, --help output usage information
259
+ -V, --version output the version number
260
+ -p, --peppers Add peppers
261
+ -P, --pineapple Add pineapple
262
+ -b, --bbq Add bbq sauce
263
+ -c, --cheese <type> Add the specified type of cheese [marble]
264
+ -C, --no-cheese You do not want any cheese
267
265
  ```
268
266
 
269
267
  ## Custom help
@@ -271,7 +269,7 @@ You can enable `--harmony` option in two ways:
271
269
  You can display arbitrary `-h, --help` information
272
270
  by listening for "--help". Commander will automatically
273
271
  exit once you are done so that the remainder of your program
274
- does not execute causing undesired behaviours, for example
272
+ does not execute causing undesired behaviors, for example
275
273
  in the following executable "stuff" will not output when
276
274
  `--help` is used.
277
275
 
@@ -294,11 +292,11 @@ program
294
292
  // node's emit() is immediate
295
293
 
296
294
  program.on('--help', function(){
297
- console.log(' Examples:');
298
- console.log('');
299
- console.log(' $ custom-help --help');
300
- console.log(' $ custom-help -h');
295
+ console.log('')
296
+ console.log('Examples:');
301
297
  console.log('');
298
+ console.log(' $ custom-help --help');
299
+ console.log(' $ custom-help -h');
302
300
  });
303
301
 
304
302
  program.parse(process.argv);
@@ -309,7 +307,6 @@ console.log('stuff');
309
307
  Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
310
308
 
311
309
  ```
312
-
313
310
  Usage: custom-help [options]
314
311
 
315
312
  Options:
@@ -324,7 +321,6 @@ Examples:
324
321
 
325
322
  $ custom-help --help
326
323
  $ custom-help -h
327
-
328
324
  ```
329
325
 
330
326
  ## .outputHelp(cb)
@@ -402,11 +398,11 @@ program
402
398
  .action(function(cmd, options){
403
399
  console.log('exec "%s" using %s mode', cmd, options.exec_mode);
404
400
  }).on('--help', function() {
405
- console.log(' Examples:');
406
- console.log();
407
- console.log(' $ deploy exec sequential');
408
- console.log(' $ deploy exec async');
409
- console.log();
401
+ console.log('');
402
+ console.log('Examples:');
403
+ console.log('');
404
+ console.log(' $ deploy exec sequential');
405
+ console.log(' $ deploy exec async');
410
406
  });
411
407
 
412
408
  program
package/index.js CHANGED
@@ -523,7 +523,7 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
523
523
  // executable
524
524
  var f = argv[1];
525
525
  // 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];
527
527
 
528
528
  // In case of globally installed, get the base dir where executable
529
529
  // subcommand file should be located at
@@ -539,11 +539,14 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
539
539
  // prefer local `./<bin>` to bin in the $PATH
540
540
  var localBin = path.join(baseDir, bin);
541
541
 
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
543
543
  var isExplicitJS = false;
544
544
  if (exists(localBin + '.js')) {
545
545
  bin = localBin + '.js';
546
546
  isExplicitJS = true;
547
+ } else if (exists(localBin + '.ts')) {
548
+ bin = localBin + '.ts';
549
+ isExplicitJS = true;
547
550
  } else if (exists(localBin)) {
548
551
  bin = localBin;
549
552
  }
@@ -577,9 +580,9 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
577
580
  proc.on('close', process.exit.bind(process));
578
581
  proc.on('error', function(err) {
579
582
  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);
581
584
  } 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);
583
586
  }
584
587
  process.exit(1);
585
588
  });
@@ -1069,12 +1072,12 @@ Command.prototype.commandHelp = function() {
1069
1072
  var width = this.padWidth();
1070
1073
 
1071
1074
  return [
1072
- ' Commands:',
1075
+ 'Commands:',
1073
1076
  '',
1074
1077
  commands.map(function(cmd) {
1075
1078
  var desc = cmd[1] ? ' ' + cmd[1] : '';
1076
1079
  return (desc ? pad(cmd[0], width) : cmd[0]) + desc;
1077
- }).join('\n').replace(/^/gm, ' '),
1080
+ }).join('\n').replace(/^/gm, ' '),
1078
1081
  ''
1079
1082
  ].join('\n');
1080
1083
  };
@@ -1090,17 +1093,17 @@ Command.prototype.helpInformation = function() {
1090
1093
  var desc = [];
1091
1094
  if (this._description) {
1092
1095
  desc = [
1093
- ' ' + this._description,
1096
+ this._description,
1094
1097
  ''
1095
1098
  ];
1096
1099
 
1097
1100
  var argsDescription = this._argsDescription;
1098
1101
  if (argsDescription && this._args.length) {
1099
1102
  var width = this.padWidth();
1100
- desc.push(' Arguments:');
1103
+ desc.push('Arguments:');
1101
1104
  desc.push('');
1102
1105
  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]);
1104
1107
  });
1105
1108
  desc.push('');
1106
1109
  }
@@ -1111,8 +1114,7 @@ Command.prototype.helpInformation = function() {
1111
1114
  cmdName = cmdName + '|' + this._alias;
1112
1115
  }
1113
1116
  var usage = [
1114
- '',
1115
- ' Usage: ' + cmdName + ' ' + this.usage(),
1117
+ 'Usage: ' + cmdName + ' ' + this.usage(),
1116
1118
  ''
1117
1119
  ];
1118
1120
 
@@ -1121,9 +1123,9 @@ Command.prototype.helpInformation = function() {
1121
1123
  if (commandHelp) cmds = [commandHelp];
1122
1124
 
1123
1125
  var options = [
1124
- ' Options:',
1126
+ 'Options:',
1125
1127
  '',
1126
- '' + this.optionHelp().replace(/^/gm, ' '),
1128
+ '' + this.optionHelp().replace(/^/gm, ' '),
1127
1129
  ''
1128
1130
  ];
1129
1131
 
@@ -1131,7 +1133,6 @@ Command.prototype.helpInformation = function() {
1131
1133
  .concat(desc)
1132
1134
  .concat(options)
1133
1135
  .concat(cmds)
1134
- .concat([''])
1135
1136
  .join('\n');
1136
1137
  };
1137
1138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commander",
3
- "version": "2.17.1",
3
+ "version": "2.18.0",
4
4
  "description": "the complete solution for node.js command-line programs",
5
5
  "keywords": [
6
6
  "commander",
@@ -26,11 +26,12 @@
26
26
  ],
27
27
  "dependencies": {},
28
28
  "devDependencies": {
29
- "@types/node": "^10.5.7",
30
- "eslint": "^5.3.0",
29
+ "@types/node": "^10.9.4",
30
+ "eslint": "^5.5.0",
31
31
  "should": "^13.2.3",
32
- "sinon": "^6.1.4",
33
- "standard": "^11.0.1",
32
+ "sinon": "^6.2.0",
33
+ "standard": "^12.0.1",
34
+ "ts-node": "^7.0.1",
34
35
  "typescript": "^2.9.2"
35
36
  },
36
37
  "typings": "typings/index.d.ts"