yargs 15.3.0-beta.0 → 15.3.1

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/README.md CHANGED
@@ -9,9 +9,9 @@
9
9
  <br>
10
10
 
11
11
  [![Build Status][travis-image]][travis-url]
12
- [![Coverage Status][coveralls-image]][coveralls-url]
13
12
  [![NPM version][npm-image]][npm-url]
14
13
  [![js-standard-style][standard-image]][standard-url]
14
+ [![Coverage][coverage-image]][coverage-url]
15
15
  [![Conventional Commits][conventional-commits-image]][conventional-commits-url]
16
16
  [![Slack][slack-image]][slack-url]
17
17
 
@@ -127,8 +127,6 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
127
127
 
128
128
  [travis-url]: https://travis-ci.org/yargs/yargs
129
129
  [travis-image]: https://img.shields.io/travis/yargs/yargs/master.svg
130
- [coveralls-url]: https://coveralls.io/github/yargs/yargs
131
- [coveralls-image]: https://img.shields.io/coveralls/yargs/yargs.svg
132
130
  [npm-url]: https://www.npmjs.com/package/yargs
133
131
  [npm-image]: https://img.shields.io/npm/v/yargs.svg
134
132
  [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
@@ -138,3 +136,5 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
138
136
  [slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
139
137
  [slack-url]: http://devtoolscommunity.herokuapp.com
140
138
  [type-definitions]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
139
+ [coverage-image]: https://img.shields.io/badge/dynamic/json?color=brightgreen&label=coverage&query=branches&suffix=%25&url=https%3A%2F%2Fraw.githubusercontent.com%2Fyargs%2Fyargs%2Fmaster%2F.nycrc&cacheSeconds=3600
140
+ [coverage-url]: https://github.com/yargs/yargs/blob/master/.nycrc
package/lib/usage.js CHANGED
@@ -273,7 +273,15 @@ module.exports = function usage (yargs, y18n) {
273
273
  // for the special positional group don't
274
274
  // add '--' or '-' prefix.
275
275
  if (groupName === self.getPositionalGroupName()) return sw
276
- else return (/^[^0-9]$/.test(sw) ? '-' : '--') + sw
276
+ else {
277
+ return (
278
+ // matches yargs-parser logic in which single-digits
279
+ // aliases declared with a boolean type are now valid
280
+ /^[0-9]$/.test(sw)
281
+ ? ~options.boolean.indexOf(key) ? '-' : '--'
282
+ : sw.length > 1 ? '--' : '-'
283
+ ) + sw
284
+ }
277
285
  })
278
286
  .join(', ')
279
287
 
@@ -500,6 +508,8 @@ module.exports = function usage (yargs, y18n) {
500
508
  // guess the width of the console window, max-width 80.
501
509
  function windowWidth () {
502
510
  const maxWidth = 80
511
+ // CI is not a TTY
512
+ /* c8 ignore next 2 */
503
513
  if (typeof process === 'object' && process.stdout && process.stdout.columns) {
504
514
  return Math.min(maxWidth, process.stdout.columns)
505
515
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yargs",
3
- "version": "15.3.0-beta.0",
3
+ "version": "15.3.1",
4
4
  "description": "yargs the modern, pirate-themed, successor to optimist.",
5
5
  "main": "./index.js",
6
6
  "contributors": [
@@ -29,13 +29,13 @@
29
29
  "string-width": "^4.2.0",
30
30
  "which-module": "^2.0.0",
31
31
  "y18n": "^4.0.0",
32
- "yargs-parser": "^18.0.0"
32
+ "yargs-parser": "^18.1.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "c8": "^7.0.0",
36
36
  "chai": "^4.2.0",
37
37
  "chalk": "^3.0.0",
38
- "coveralls": "^3.0.3",
38
+ "coveralls": "^3.0.9",
39
39
  "cpr": "^3.0.1",
40
40
  "cross-spawn": "^7.0.0",
41
41
  "es6-promise": "^4.2.5",
@@ -49,8 +49,8 @@
49
49
  "scripts": {
50
50
  "fix": "standard --fix",
51
51
  "posttest": "standard",
52
- "test": "c8 --reporter=html --reporter=text mocha --require ./test/before.js --timeout=12000 --check-leaks",
53
- "coverage": "c8 report --reporter=text-lcov | coveralls"
52
+ "test": "c8 mocha --require ./test/before.js --timeout=12000 --check-leaks",
53
+ "coverage": "c8 report --check-coverage"
54
54
  },
55
55
  "repository": {
56
56
  "type": "git",
package/yargs.js CHANGED
@@ -235,9 +235,18 @@ function Yargs (processArgs, cwd, parentRequire) {
235
235
  return self
236
236
  }
237
237
 
238
- self.requiresArg = function (keys) {
239
- argsert('<array|string>', [keys], arguments.length)
240
- populateParserHintObject(self.nargs, false, 'narg', keys, NaN)
238
+ self.requiresArg = function (keys, value) {
239
+ argsert('<array|string|object> [number]', [keys], arguments.length)
240
+ // If someone configures nargs at the same time as requiresArg,
241
+ // nargs should take precedent,
242
+ // see: https://github.com/yargs/yargs/pull/1572
243
+ // TODO: make this work with aliases, using a check similar to
244
+ // checkAllAliases() in yargs-parser.
245
+ if (typeof keys === 'string' && options.narg[keys]) {
246
+ return self
247
+ } else {
248
+ populateParserHintObject(self.requiresArg, false, 'narg', keys, NaN)
249
+ }
241
250
  return self
242
251
  }
243
252
 
@@ -250,6 +259,7 @@ function Yargs (processArgs, cwd, parentRequire) {
250
259
  function populateParserHintArray (type, keys, value) {
251
260
  keys = [].concat(keys)
252
261
  keys.forEach((key) => {
262
+ key = sanitizeKey(key)
253
263
  options[type].push(key)
254
264
  })
255
265
  }
@@ -305,8 +315,8 @@ function Yargs (processArgs, cwd, parentRequire) {
305
315
 
306
316
  function populateParserHintObject (builder, isArray, type, key, value) {
307
317
  if (Array.isArray(key)) {
318
+ const temp = Object.create(null)
308
319
  // an array of keys with one value ['x', 'y', 'z'], function parse () {}
309
- const temp = {}
310
320
  key.forEach((k) => {
311
321
  temp[k] = value
312
322
  })
@@ -317,6 +327,7 @@ function Yargs (processArgs, cwd, parentRequire) {
317
327
  builder(k, key[k])
318
328
  })
319
329
  } else {
330
+ key = sanitizeKey(key)
320
331
  // a single key value pair 'x', parse() {}
321
332
  if (isArray) {
322
333
  options[type][key] = (options[type][key] || []).concat(value)
@@ -326,6 +337,13 @@ function Yargs (processArgs, cwd, parentRequire) {
326
337
  }
327
338
  }
328
339
 
340
+ // TODO(bcoe): in future major versions move more objects towards
341
+ // Object.create(null):
342
+ function sanitizeKey (key) {
343
+ if (key === '__proto__') return '___proto___'
344
+ return key
345
+ }
346
+
329
347
  function deleteFromParserHintObject (optionKey) {
330
348
  // delete from all parsing hints:
331
349
  // boolean, array, key, alias, etc.