commander 2.8.0 → 2.11.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.
Files changed (4) hide show
  1. package/History.md +49 -0
  2. package/Readme.md +30 -22
  3. package/index.js +89 -75
  4. package/package.json +5 -9
package/History.md CHANGED
@@ -1,4 +1,53 @@
1
1
 
2
+ 2.11.0 / 2017-07-03
3
+ ==================
4
+
5
+ * Fix help section order and padding (#652)
6
+ * feature: support for signals to subcommands (#632)
7
+ * Fixed #37, --help should not display first (#447)
8
+ * Fix translation errors. (#570)
9
+ * Add package-lock.json
10
+ * Remove engines
11
+ * Upgrade package version
12
+ * Prefix events to prevent conflicts between commands and options (#494)
13
+ * Removing dependency on graceful-readlink
14
+ * Support setting name in #name function and make it chainable
15
+ * Add .vscode directory to .gitignore (Visual Studio Code metadata)
16
+ * Updated link to ruby commander in readme files
17
+
18
+ 2.10.0 / 2017-06-19
19
+ ==================
20
+
21
+ * Update .travis.yml. drop support for older node.js versions.
22
+ * Fix require arguments in README.md
23
+ * On SemVer you do not start from 0.0.1
24
+ * Add missing semi colon in readme
25
+ * Add save param to npm install
26
+ * node v6 travis test
27
+ * Update Readme_zh-CN.md
28
+ * Allow literal '--' to be passed-through as an argument
29
+ * Test subcommand alias help
30
+ * link build badge to master branch
31
+ * Support the alias of Git style sub-command
32
+ * added keyword commander for better search result on npm
33
+ * Fix Sub-Subcommands
34
+ * test node.js stable
35
+ * Fixes TypeError when a command has an option called `--description`
36
+ * Update README.md to make it beginner friendly and elaborate on the difference between angled and square brackets.
37
+ * Add chinese Readme file
38
+
39
+ 2.9.0 / 2015-10-13
40
+ ==================
41
+
42
+ * Add option `isDefault` to set default subcommand #415 @Qix-
43
+ * Add callback to allow filtering or post-processing of help text #434 @djulien
44
+ * Fix `undefined` text in help information close #414 #416 @zhiyelee
45
+
46
+ 2.8.1 / 2015-04-22
47
+ ==================
48
+
49
+ * Back out `support multiline description` Close #396 #397
50
+
2
51
  2.8.0 / 2015-04-07
3
52
  ==================
4
53
 
package/Readme.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Commander.js
2
2
 
3
3
 
4
- [![Build Status](https://api.travis-ci.org/tj/commander.js.svg)](http://travis-ci.org/tj/commander.js)
4
+ [![Build Status](https://api.travis-ci.org/tj/commander.js.svg?branch=master)](http://travis-ci.org/tj/commander.js)
5
5
  [![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
6
6
  [![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
7
7
  [![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
 
9
- The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander).
9
+ The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander).
10
10
  [API documentation](http://tj.github.com/commander.js/)
11
11
 
12
12
 
13
13
  ## Installation
14
14
 
15
- $ npm install commander
15
+ $ npm install commander --save
16
16
 
17
17
  ## Option parsing
18
18
 
@@ -28,7 +28,7 @@
28
28
  var program = require('commander');
29
29
 
30
30
  program
31
- .version('0.0.1')
31
+ .version('0.1.0')
32
32
  .option('-p, --peppers', 'Add peppers')
33
33
  .option('-P, --pineapple', 'Add pineapple')
34
34
  .option('-b, --bbq-sauce', 'Add bbq sauce')
@@ -66,7 +66,7 @@ function increaseVerbosity(v, total) {
66
66
  }
67
67
 
68
68
  program
69
- .version('0.0.1')
69
+ .version('0.1.0')
70
70
  .usage('[options] <file ...>')
71
71
  .option('-i, --integer <n>', 'An integer argument', parseInt)
72
72
  .option('-f, --float <n>', 'A float argument', parseFloat)
@@ -91,7 +91,7 @@ console.log(' args: %j', program.args);
91
91
  ## Regular Expression
92
92
  ```js
93
93
  program
94
- .version('0.0.1')
94
+ .version('0.1.0')
95
95
  .option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
96
96
  .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
97
97
  .parse(process.argv);
@@ -115,7 +115,7 @@ console.log(' drink: %j', program.drink);
115
115
  var program = require('commander');
116
116
 
117
117
  program
118
- .version('0.0.1')
118
+ .version('0.1.0')
119
119
  .command('rmdir <dir> [otherDirs...]')
120
120
  .action(function (dir, otherDirs) {
121
121
  console.log('rmdir %s', dir);
@@ -137,10 +137,10 @@ program.parse(process.argv);
137
137
  ```js
138
138
  #!/usr/bin/env node
139
139
 
140
- var program = require('../');
140
+ var program = require('commander');
141
141
 
142
142
  program
143
- .version('0.0.1')
143
+ .version('0.1.0')
144
144
  .arguments('<cmd> [env]')
145
145
  .action(function (cmd, env) {
146
146
  cmdValue = cmd;
@@ -156,24 +156,27 @@ if (typeof cmdValue === 'undefined') {
156
156
  console.log('command:', cmdValue);
157
157
  console.log('environment:', envValue || "no environment given");
158
158
  ```
159
+ Angled brackets (e.g. `<cmd>`) indicate required input. Square brackets (e.g. `[env]`) indicate optional input.
159
160
 
160
161
  ## Git-style sub-commands
161
162
 
162
163
  ```js
163
164
  // file: ./examples/pm
164
- var program = require('..');
165
+ var program = require('commander');
165
166
 
166
167
  program
167
- .version('0.0.1')
168
+ .version('0.1.0')
168
169
  .command('install [name]', 'install one or more packages')
169
170
  .command('search [query]', 'search with optional query')
170
- .command('list', 'list packages installed')
171
+ .command('list', 'list packages installed', {isDefault: true})
171
172
  .parse(process.argv);
172
173
  ```
173
174
 
174
175
  When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
175
176
  The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
176
177
 
178
+ Options can be passed with the call to `.command()`. Specifying `true` for `opts.noHelp` will remove the option from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified.
179
+
177
180
  If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
178
181
 
179
182
  ### `--harmony`
@@ -200,8 +203,7 @@ You can enable `--harmony` option in two ways:
200
203
  -p, --peppers Add peppers
201
204
  -P, --pineapple Add pineapple
202
205
  -b, --bbq Add bbq sauce
203
- -c, --cheese <type> Add the specified type
204
- of cheese [marble]
206
+ -c, --cheese <type> Add the specified type of cheese [marble]
205
207
  -C, --no-cheese You do not want any cheese
206
208
 
207
209
  ```
@@ -225,7 +227,7 @@ You can enable `--harmony` option in two ways:
225
227
  var program = require('commander');
226
228
 
227
229
  program
228
- .version('0.0.1')
230
+ .version('0.1.0')
229
231
  .option('-f, --foo', 'enable some foo')
230
232
  .option('-b, --bar', 'enable some bar')
231
233
  .option('-B, --baz', 'enable some baz');
@@ -267,28 +269,35 @@ Examples:
267
269
 
268
270
  ```
269
271
 
270
- ## .outputHelp()
272
+ ## .outputHelp(cb)
271
273
 
272
274
  Output help information without exiting.
275
+ Optional callback cb allows post-processing of help text before it is displayed.
273
276
 
274
277
  If you want to display help by default (e.g. if no command was provided), you can use something like:
275
278
 
276
279
  ```js
277
280
  var program = require('commander');
281
+ var colors = require('colors');
278
282
 
279
283
  program
280
- .version('0.0.1')
284
+ .version('0.1.0')
281
285
  .command('getstream [url]', 'get stream URL')
282
286
  .parse(process.argv);
283
287
 
284
288
  if (!process.argv.slice(2).length) {
285
- program.outputHelp();
289
+ program.outputHelp(make_red);
286
290
  }
291
+
292
+ function make_red(txt) {
293
+ return colors.red(txt); //display the help text in red on the console
294
+ }
287
295
  ```
288
296
 
289
- ## .help()
297
+ ## .help(cb)
290
298
 
291
299
  Output help information and exit immediately.
300
+ Optional callback cb allows post-processing of help text before it is displayed.
292
301
 
293
302
  ## Examples
294
303
 
@@ -296,10 +305,10 @@ program
296
305
  var program = require('commander');
297
306
 
298
307
  program
299
- .version('0.0.1')
308
+ .version('0.1.0')
300
309
  .option('-C, --chdir <path>', 'change the working directory')
301
310
  .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
302
- .option('-T, --no-tests', 'ignore test hook')
311
+ .option('-T, --no-tests', 'ignore test hook');
303
312
 
304
313
  program
305
314
  .command('setup [env]')
@@ -340,4 +349,3 @@ More Demos can be found in the [examples](https://github.com/tj/commander.js/tre
340
349
  ## License
341
350
 
342
351
  MIT
343
-
package/index.js CHANGED
@@ -1,11 +1,9 @@
1
-
2
1
  /**
3
2
  * Module dependencies.
4
3
  */
5
4
 
6
5
  var EventEmitter = require('events').EventEmitter;
7
6
  var spawn = require('child_process').spawn;
8
- var readlink = require('graceful-readlink').readlinkSync;
9
7
  var path = require('path');
10
8
  var dirname = path.dirname;
11
9
  var basename = path.basename;
@@ -83,10 +81,10 @@ Option.prototype.is = function(arg) {
83
81
  function Command(name) {
84
82
  this.commands = [];
85
83
  this.options = [];
86
- this._execs = [];
84
+ this._execs = {};
87
85
  this._allowUnknownOption = false;
88
86
  this._args = [];
89
- this._name = name;
87
+ this._name = name || '';
90
88
  }
91
89
 
92
90
  /**
@@ -165,6 +163,7 @@ Command.prototype.command = function(name, desc, opts) {
165
163
  cmd.description(desc);
166
164
  this.executables = true;
167
165
  this._execs[cmd._name] = true;
166
+ if (opts.isDefault) this.defaultExecutable = cmd._name;
168
167
  }
169
168
 
170
169
  cmd._noHelp = !!opts.noHelp;
@@ -184,7 +183,7 @@ Command.prototype.command = function(name, desc, opts) {
184
183
 
185
184
  Command.prototype.arguments = function (desc) {
186
185
  return this.parseExpectedArgs(desc.split(/ +/));
187
- }
186
+ };
188
187
 
189
188
  /**
190
189
  * Add an implicit `help [cmd]` subcommand
@@ -302,8 +301,8 @@ Command.prototype.action = function(fn) {
302
301
  };
303
302
  var parent = this.parent || this;
304
303
  var name = parent === this ? '*' : this._name;
305
- parent.on(name, listener);
306
- if (this._alias) parent.on(this._alias, listener);
304
+ parent.on('command:' + name, listener);
305
+ if (this._alias) parent.on('command:' + this._alias, listener);
307
306
  return this;
308
307
  };
309
308
 
@@ -350,8 +349,8 @@ Command.prototype.action = function(fn) {
350
349
  *
351
350
  * @param {String} flags
352
351
  * @param {String} description
353
- * @param {Function|Mixed} fn or default
354
- * @param {Mixed} defaultValue
352
+ * @param {Function|*} [fn] or default
353
+ * @param {*} [defaultValue]
355
354
  * @return {Command} for chaining
356
355
  * @api public
357
356
  */
@@ -390,7 +389,7 @@ Command.prototype.option = function(flags, description, fn, defaultValue) {
390
389
 
391
390
  // when it's passed assign the value
392
391
  // and conditionally invoke the callback
393
- this.on(oname, function(val) {
392
+ this.on('option:' + oname, function(val) {
394
393
  // coercion
395
394
  if (null !== val && fn) val = fn(val, undefined === self[name]
396
395
  ? defaultValue
@@ -446,7 +445,7 @@ Command.prototype.parse = function(argv) {
446
445
  this._name = this._name || basename(argv[1], '.js');
447
446
 
448
447
  // github-style sub-commands with no sub-command
449
- if (this.executables && argv.length < 3) {
448
+ if (this.executables && argv.length < 3 && !this.defaultExecutable) {
450
449
  // this user needs help
451
450
  argv.push('--help');
452
451
  }
@@ -459,8 +458,25 @@ Command.prototype.parse = function(argv) {
459
458
 
460
459
  // executable sub-commands
461
460
  var name = result.args[0];
461
+
462
+ var aliasCommand = null;
463
+ // check alias of sub commands
464
+ if (name) {
465
+ aliasCommand = this.commands.filter(function(command) {
466
+ return command.alias() === name;
467
+ })[0];
468
+ }
469
+
462
470
  if (this._execs[name] && typeof this._execs[name] != "function") {
463
471
  return this.executeSubCommand(argv, args, parsed.unknown);
472
+ } else if (aliasCommand) {
473
+ // is alias of a subCommand
474
+ args[0] = aliasCommand._name;
475
+ return this.executeSubCommand(argv, args, parsed.unknown);
476
+ } else if (this.defaultExecutable) {
477
+ // use the default subcommand
478
+ args.unshift(this.defaultExecutable);
479
+ return this.executeSubCommand(argv, args, parsed.unknown);
464
480
  }
465
481
 
466
482
  return result;
@@ -496,7 +512,7 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
496
512
  // In case of globally installed, get the base dir where executable
497
513
  // subcommand file should be located at
498
514
  var baseDir
499
- , link = readlink(f);
515
+ , link = fs.lstatSync(f).isSymbolicLink() ? fs.readlinkSync(f) : f;
500
516
 
501
517
  // when symbolink is relative path
502
518
  if (link !== f && link.charAt(0) !== '/') {
@@ -521,7 +537,7 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
521
537
  var proc;
522
538
  if (process.platform !== 'win32') {
523
539
  if (isExplicitJS) {
524
- args.unshift(localBin);
540
+ args.unshift(bin);
525
541
  // add executable arguments to spawn
526
542
  args = (process.execArgv || []).concat(args);
527
543
 
@@ -530,10 +546,18 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
530
546
  proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
531
547
  }
532
548
  } else {
533
- args.unshift(localBin);
549
+ args.unshift(bin);
534
550
  proc = spawn(process.execPath, args, { stdio: 'inherit'});
535
551
  }
536
552
 
553
+ var signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP'];
554
+ signals.forEach(function(signal) {
555
+ process.on(signal, function(){
556
+ if ((proc.killed === false) && (proc.exitCode === null)){
557
+ proc.kill(signal);
558
+ }
559
+ });
560
+ });
537
561
  proc.on('close', process.exit.bind(process));
538
562
  proc.on('error', function(err) {
539
563
  if (err.code == "ENOENT") {
@@ -544,6 +568,7 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
544
568
  process.exit(1);
545
569
  });
546
570
 
571
+ // Store the reference to the child process
547
572
  this.runningCommand = proc;
548
573
  };
549
574
 
@@ -606,10 +631,10 @@ Command.prototype.parseArgs = function(args, unknown) {
606
631
 
607
632
  if (args.length) {
608
633
  name = args[0];
609
- if (this.listeners(name).length) {
610
- this.emit(args.shift(), args, unknown);
634
+ if (this.listeners('command:' + name).length) {
635
+ this.emit('command:' + args.shift(), args, unknown);
611
636
  } else {
612
- this.emit('*', args);
637
+ this.emit('command:*', args);
613
638
  }
614
639
  } else {
615
640
  outputHelpIfNecessary(this, unknown);
@@ -663,13 +688,13 @@ Command.prototype.parseOptions = function(argv) {
663
688
  arg = argv[i];
664
689
 
665
690
  // literal args after --
666
- if ('--' == arg) {
667
- literal = true;
691
+ if (literal) {
692
+ args.push(arg);
668
693
  continue;
669
694
  }
670
695
 
671
- if (literal) {
672
- args.push(arg);
696
+ if ('--' == arg) {
697
+ literal = true;
673
698
  continue;
674
699
  }
675
700
 
@@ -682,7 +707,7 @@ Command.prototype.parseOptions = function(argv) {
682
707
  if (option.required) {
683
708
  arg = argv[++i];
684
709
  if (null == arg) return this.optionMissingArgument(option);
685
- this.emit(option.name(), arg);
710
+ this.emit('option:' + option.name(), arg);
686
711
  // optional arg
687
712
  } else if (option.optional) {
688
713
  arg = argv[i+1];
@@ -691,10 +716,10 @@ Command.prototype.parseOptions = function(argv) {
691
716
  } else {
692
717
  ++i;
693
718
  }
694
- this.emit(option.name(), arg);
719
+ this.emit('option:' + option.name(), arg);
695
720
  // bool
696
721
  } else {
697
- this.emit(option.name());
722
+ this.emit('option:' + option.name());
698
723
  }
699
724
  continue;
700
725
  }
@@ -805,7 +830,7 @@ Command.prototype.variadicArgNotLast = function(name) {
805
830
  * which will print the version number when passed.
806
831
  *
807
832
  * @param {String} str
808
- * @param {String} flags
833
+ * @param {String} [flags]
809
834
  * @return {Command} for chaining
810
835
  * @api public
811
836
  */
@@ -815,7 +840,7 @@ Command.prototype.version = function(str, flags) {
815
840
  this._version = str;
816
841
  flags = flags || '-V, --version';
817
842
  this.option(flags, 'output the version number');
818
- this.on('version', function() {
843
+ this.on('option:version', function() {
819
844
  process.stdout.write(str + '\n');
820
845
  process.exit(0);
821
846
  });
@@ -831,7 +856,7 @@ Command.prototype.version = function(str, flags) {
831
856
  */
832
857
 
833
858
  Command.prototype.description = function(str) {
834
- if (0 == arguments.length) return this._description;
859
+ if (0 === arguments.length) return this._description;
835
860
  this._description = str;
836
861
  return this;
837
862
  };
@@ -845,8 +870,14 @@ Command.prototype.description = function(str) {
845
870
  */
846
871
 
847
872
  Command.prototype.alias = function(alias) {
848
- if (0 == arguments.length) return this._alias;
849
- this._alias = alias;
873
+ var command = this;
874
+ if(this.commands.length !== 0) {
875
+ command = this.commands[this.commands.length - 1]
876
+ }
877
+
878
+ if (arguments.length === 0) return command._alias;
879
+
880
+ command._alias = alias;
850
881
  return this;
851
882
  };
852
883
 
@@ -874,15 +905,17 @@ Command.prototype.usage = function(str) {
874
905
  };
875
906
 
876
907
  /**
877
- * Get the name of the command
908
+ * Get or set the name of the command
878
909
  *
879
- * @param {String} name
910
+ * @param {String} str
880
911
  * @return {String|Command}
881
912
  * @api public
882
913
  */
883
914
 
884
- Command.prototype.name = function() {
885
- return this._name;
915
+ Command.prototype.name = function(str) {
916
+ if (0 === arguments.length) return this._name;
917
+ this._name = str;
918
+ return this;
886
919
  };
887
920
 
888
921
  /**
@@ -908,11 +941,10 @@ Command.prototype.largestOptionLength = function() {
908
941
  Command.prototype.optionHelp = function() {
909
942
  var width = this.largestOptionLength();
910
943
 
911
- // Prepend the help information
912
- return [pad('-h, --help', width) + ' ' + 'output usage information']
913
- .concat(this.options.map(function(option) {
914
- return pad(option.flags, width) + ' ' + offset(option.description, width + 2);
915
- }))
944
+ // Append the help information
945
+ return this.options.map(function(option) {
946
+ return pad(option.flags, width) + ' ' + option.description;
947
+ }).concat([pad('-h, --help', width) + ' ' + 'output usage information'])
916
948
  .join('\n');
917
949
  };
918
950
 
@@ -935,14 +967,10 @@ Command.prototype.commandHelp = function() {
935
967
 
936
968
  return [
937
969
  cmd._name
938
- + (cmd._alias
939
- ? '|' + cmd._alias
940
- : '')
941
- + (cmd.options.length
942
- ? ' [options]'
943
- : '')
970
+ + (cmd._alias ? '|' + cmd._alias : '')
971
+ + (cmd.options.length ? ' [options]' : '')
944
972
  + ' ' + args
945
- , cmd.description()
973
+ , cmd._description
946
974
  ];
947
975
  });
948
976
 
@@ -951,11 +979,12 @@ Command.prototype.commandHelp = function() {
951
979
  }, 0);
952
980
 
953
981
  return [
954
- ''
982
+ ''
955
983
  , ' Commands:'
956
984
  , ''
957
985
  , commands.map(function(cmd) {
958
- return pad(cmd[0], width) + ' ' + offset(cmd[1], width + 2);
986
+ var desc = cmd[1] ? ' ' + cmd[1] : '';
987
+ return pad(cmd[0], width) + desc;
959
988
  }).join('\n').replace(/^/gm, ' ')
960
989
  , ''
961
990
  ].join('\n');
@@ -983,7 +1012,7 @@ Command.prototype.helpInformation = function() {
983
1012
  }
984
1013
  var usage = [
985
1014
  ''
986
- ,' Usage: ' + cmdName + ' ' + offset(this.usage(), 9)
1015
+ ,' Usage: ' + cmdName + ' ' + this.usage()
987
1016
  , ''
988
1017
  ];
989
1018
 
@@ -992,17 +1021,17 @@ Command.prototype.helpInformation = function() {
992
1021
  if (commandHelp) cmds = [commandHelp];
993
1022
 
994
1023
  var options = [
995
- ' Options:'
1024
+ ''
1025
+ , ' Options:'
996
1026
  , ''
997
1027
  , '' + this.optionHelp().replace(/^/gm, ' ')
998
1028
  , ''
999
- , ''
1000
1029
  ];
1001
1030
 
1002
1031
  return usage
1003
- .concat(cmds)
1004
1032
  .concat(desc)
1005
1033
  .concat(options)
1034
+ .concat(cmds)
1006
1035
  .join('\n');
1007
1036
  };
1008
1037
 
@@ -1012,8 +1041,13 @@ Command.prototype.helpInformation = function() {
1012
1041
  * @api public
1013
1042
  */
1014
1043
 
1015
- Command.prototype.outputHelp = function() {
1016
- process.stdout.write(this.helpInformation());
1044
+ Command.prototype.outputHelp = function(cb) {
1045
+ if (!cb) {
1046
+ cb = function(passthru) {
1047
+ return passthru;
1048
+ }
1049
+ }
1050
+ process.stdout.write(cb(this.helpInformation()));
1017
1051
  this.emit('--help');
1018
1052
  };
1019
1053
 
@@ -1023,8 +1057,8 @@ Command.prototype.outputHelp = function() {
1023
1057
  * @api public
1024
1058
  */
1025
1059
 
1026
- Command.prototype.help = function() {
1027
- this.outputHelp();
1060
+ Command.prototype.help = function(cb) {
1061
+ this.outputHelp(cb);
1028
1062
  process.exit();
1029
1063
  };
1030
1064
 
@@ -1056,23 +1090,6 @@ function pad(str, width) {
1056
1090
  return str + Array(len + 1).join(' ');
1057
1091
  }
1058
1092
 
1059
- /**
1060
- * Prepend to each line of `str` spaced string of `offset` length.
1061
- *
1062
- * @param {String} str
1063
- * @param {Number} offset
1064
- * @param {Boolean} skipFirstLine
1065
- * @return {String}
1066
- * @api private
1067
- */
1068
- function offset(str, offset, skipFirstLine) {
1069
- var res = String(str || '').replace(/^/gm, pad('', offset));
1070
- if (!skipFirstLine) {
1071
- res = res.replace(/^\s+/, '');
1072
- }
1073
- return res;
1074
- }
1075
-
1076
1093
  /**
1077
1094
  * Output help information if necessary
1078
1095
  *
@@ -1087,9 +1104,6 @@ function outputHelpIfNecessary(cmd, options) {
1087
1104
  if (options[i] == '--help' || options[i] == '-h') {
1088
1105
  cmd.outputHelp();
1089
1106
  process.exit(0);
1090
-
1091
- // used for test flow only
1092
- options.splice(i, 1);
1093
1107
  }
1094
1108
  }
1095
1109
  }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "commander",
3
- "version": "2.8.0",
3
+ "version": "2.11.0",
4
4
  "description": "the complete solution for node.js command-line programs",
5
5
  "keywords": [
6
+ "commander",
6
7
  "command",
7
8
  "option",
8
9
  "parser"
@@ -14,20 +15,15 @@
14
15
  "url": "https://github.com/tj/commander.js.git"
15
16
  },
16
17
  "devDependencies": {
17
- "should": ">= 0.0.1",
18
- "sinon": ">= 1.13.0"
18
+ "should": "^11.2.1",
19
+ "sinon": "^2.3.5"
19
20
  },
20
21
  "scripts": {
21
22
  "test": "make test"
22
23
  },
23
24
  "main": "index",
24
- "engines": {
25
- "node": ">= 0.6.x"
26
- },
27
25
  "files": [
28
26
  "index.js"
29
27
  ],
30
- "dependencies": {
31
- "graceful-readlink": ">= 1.0.0"
32
- }
28
+ "dependencies": {}
33
29
  }