yargs 3.14.0 → 3.15.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,5 +1,9 @@
1
1
  ## Change Log
2
2
 
3
+ ### v3.15.0 (2015/07/06 06:01 +00:00)
4
+ - [#197](https://github.com/bcoe/yargs/pull/197) tweaks to how errors bubble up from parser.js (@bcoe)
5
+ - [#193](https://github.com/bcoe/yargs/pull/193) upgraded nyc, reporting now happens by default (@bcoe)
6
+
3
7
  ### v3.14.0 (2015/06/28 02:12 +00:00)
4
8
 
5
9
  - [#192](https://github.com/bcoe/yargs/pull/192) standard style nits (@bcoe)
package/index.js CHANGED
@@ -476,6 +476,8 @@ function Argv (processArgs, cwd) {
476
476
  }
477
477
  })
478
478
 
479
+ if (parsed.error) throw parsed.error
480
+
479
481
  // if we're executed via bash completion, don't
480
482
  // bother with validation.
481
483
  if (!argv[completion.completionKey]) {
package/lib/parser.js CHANGED
@@ -9,6 +9,8 @@ function increment (orig) {
9
9
 
10
10
  module.exports = function (args, opts) {
11
11
  if (!opts) opts = {}
12
+
13
+ var error = null
12
14
  var flags = { arrays: {}, bools: {}, strings: {}, counts: {}, normalize: {}, configs: {} }
13
15
 
14
16
  ;[].concat(opts['array']).filter(Boolean).forEach(function (key) {
@@ -232,7 +234,7 @@ module.exports = function (args, opts) {
232
234
  function eatNargs (i, key, args) {
233
235
  var toEat = checkAllAliases(key, opts.narg)
234
236
 
235
- if (args.length - (i + 1) < toEat) throw Error('not enough arguments following: ' + key)
237
+ if (args.length - (i + 1) < toEat) error = Error('not enough arguments following: ' + key)
236
238
 
237
239
  for (var ii = i + 1; ii < (toEat + i + 1); ii++) {
238
240
  setArg(key, args[ii])
@@ -331,7 +333,7 @@ module.exports = function (args, opts) {
331
333
  }
332
334
  })
333
335
  } catch (ex) {
334
- throw Error('invalid json config file: ' + configPath)
336
+ if (argv[configKey]) error = Error('invalid json config file: ' + configPath)
335
337
  }
336
338
  }
337
339
  })
@@ -443,6 +445,7 @@ module.exports = function (args, opts) {
443
445
  return {
444
446
  argv: argv,
445
447
  aliases: aliases,
448
+ error: error,
446
449
  newAliases: newAliases
447
450
  }
448
451
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yargs",
3
- "version": "3.14.0",
3
+ "version": "3.15.0",
4
4
  "description": "Light-weight option parsing with an argv hash. No optstrings attached.",
5
5
  "main": "./index.js",
6
6
  "files": [
@@ -20,11 +20,11 @@
20
20
  "coveralls": "^2.11.2",
21
21
  "hashish": "0.0.4",
22
22
  "mocha": "^2.2.1",
23
- "nyc": "^2.2.1",
23
+ "nyc": "^3.0.0",
24
24
  "standard": "^4.4.0"
25
25
  },
26
26
  "scripts": {
27
- "test": "standard && nyc mocha --check-leaks && nyc report",
27
+ "test": "standard && nyc mocha --check-leaks",
28
28
  "coverage": "nyc report --reporter=text-lcov | coveralls"
29
29
  },
30
30
  "repository": {