yargs 3.22.2 → 3.23.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 +6 -0
- package/README.md +5 -3
- package/index.js +4 -9
- package/lib/locale.js +19 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v3.23.0 (2015/08/30 23:00 +00:00)
|
|
4
|
+
|
|
5
|
+
- [#246](https://github.com/bcoe/yargs/pull/246) detect locale based only on environment variables (@bcoe)
|
|
6
|
+
- [#244](https://github.com/bcoe/yargs/pull/244) adds Windows CI testing (@bcoe)
|
|
7
|
+
- [#245](https://github.com/bcoe/yargs/pull/245) adds OSX CI testing (@bcoe, @nexdrew)
|
|
8
|
+
|
|
3
9
|
### v3.22.0 (2015/08/28 22:26 +00:00)
|
|
4
10
|
- [#242](https://github.com/bcoe/yargs/pull/242) adds detectLocale config option (@bcoe)
|
|
5
11
|
|
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ With yargs, ye be havin' a map that leads straight to yer treasure! Treasure of
|
|
|
9
9
|
[![Dependency Status][gemnasium-image]][gemnasium-url]
|
|
10
10
|
[![Coverage Status][coveralls-image]][coveralls-url]
|
|
11
11
|
[![NPM version][npm-image]][npm-url]
|
|
12
|
+
[![Windows Tests][windows-image]][windows-url]
|
|
12
13
|
|
|
13
14
|
> Yargs is the official successor to optimist. Please feel free to submit issues and pull requests. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/bcoe/yargs/issues) :)
|
|
14
15
|
|
|
@@ -655,8 +656,7 @@ Optionally `.implies()` can accept an object specifying multiple implications.
|
|
|
655
656
|
|
|
656
657
|
Return the locale that yargs is currently using.
|
|
657
658
|
|
|
658
|
-
By default, yargs will auto-detect the operating system's locale
|
|
659
|
-
(via [os-locale](https://www.npmjs.com/package/os-locale)) so that
|
|
659
|
+
By default, yargs will auto-detect the operating system's locale so that
|
|
660
660
|
yargs-generated help content will display in the user's language.
|
|
661
661
|
|
|
662
662
|
To override this behavior with a static locale, pass the desired locale as a
|
|
@@ -720,7 +720,7 @@ To submit a new translation for yargs:
|
|
|
720
720
|
.detectLocale(boolean)
|
|
721
721
|
-----------
|
|
722
722
|
|
|
723
|
-
Should yargs attempt to detect the os' locale? defaults to `
|
|
723
|
+
Should yargs attempt to detect the os' locale? defaults to `true`.
|
|
724
724
|
|
|
725
725
|
.nargs(key, count)
|
|
726
726
|
-----------
|
|
@@ -1089,3 +1089,5 @@ This module is loosely inspired by Perl's
|
|
|
1089
1089
|
[coveralls-image]: https://img.shields.io/coveralls/bcoe/yargs.svg
|
|
1090
1090
|
[npm-url]: https://npmjs.org/package/yargs
|
|
1091
1091
|
[npm-image]: https://img.shields.io/npm/v/yargs.svg
|
|
1092
|
+
[windows-url]: https://ci.appveyor.com/project/bcoe/yargs
|
|
1093
|
+
[windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs/master.svg?label=Windows%20Tests
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var assert = require('assert')
|
|
2
2
|
var Completion = require('./lib/completion')
|
|
3
|
+
var locale = require('./lib/locale')
|
|
3
4
|
var Parser = require('./lib/parser')
|
|
4
5
|
var path = require('path')
|
|
5
6
|
var Usage = require('./lib/usage')
|
|
@@ -416,11 +417,12 @@ function Argv (processArgs, cwd) {
|
|
|
416
417
|
}
|
|
417
418
|
|
|
418
419
|
self.updateStrings = self.updateLocale = function (obj) {
|
|
420
|
+
detectLocale = false
|
|
419
421
|
y18n.updateLocale(obj)
|
|
420
422
|
return self
|
|
421
423
|
}
|
|
422
424
|
|
|
423
|
-
var detectLocale =
|
|
425
|
+
var detectLocale = true
|
|
424
426
|
self.detectLocale = function (detect) {
|
|
425
427
|
detectLocale = detect
|
|
426
428
|
return self
|
|
@@ -546,14 +548,7 @@ function Argv (processArgs, cwd) {
|
|
|
546
548
|
|
|
547
549
|
function guessLocale () {
|
|
548
550
|
if (!detectLocale) return
|
|
549
|
-
|
|
550
|
-
try {
|
|
551
|
-
var osLocale = require('os-locale')
|
|
552
|
-
self.locale(osLocale.sync())
|
|
553
|
-
} catch (err) {
|
|
554
|
-
// if we explode looking up locale just noop
|
|
555
|
-
// we'll keep using the default language 'en'.
|
|
556
|
-
}
|
|
551
|
+
self.locale(locale())
|
|
557
552
|
}
|
|
558
553
|
|
|
559
554
|
function setPlaceholderKeys (argv) {
|
package/lib/locale.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// port of https://github.com/sindresorhus/os-locale
|
|
2
|
+
// that only looks at environment variables.
|
|
3
|
+
module.exports = function () {
|
|
4
|
+
return getEnvLocale()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getEnvLocale () {
|
|
8
|
+
var env = process.env
|
|
9
|
+
var ret = env.LC_ALL || env.LANGUAGE || env.LANG || env.LC_MESSAGES
|
|
10
|
+
return getLocale(ret)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getLocale (str) {
|
|
14
|
+
return (str && str.replace(/[.:].*/, '')) || fallback()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function fallback () {
|
|
18
|
+
return 'en_US'
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.0",
|
|
4
4
|
"description": "Light-weight option parsing with an argv hash. No optstrings attached.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"camelcase": "^1.2.1",
|
|
15
15
|
"cliui": "^2.1.0",
|
|
16
16
|
"decamelize": "^1.0.0",
|
|
17
|
-
"os-locale": "^1.2.1",
|
|
18
17
|
"window-size": "^0.1.2",
|
|
19
18
|
"y18n": "^3.1.0"
|
|
20
19
|
},
|
|
@@ -22,12 +21,13 @@
|
|
|
22
21
|
"chai": "^3.2.0",
|
|
23
22
|
"coveralls": "^2.11.4",
|
|
24
23
|
"hashish": "0.0.4",
|
|
25
|
-
"mocha": "^2.
|
|
24
|
+
"mocha": "^2.3.0",
|
|
26
25
|
"nyc": "^3.1.0",
|
|
27
26
|
"standard": "^5.1.1"
|
|
28
27
|
},
|
|
29
28
|
"scripts": {
|
|
30
29
|
"test": "standard && nyc mocha --timeout=4000 --check-leaks",
|
|
30
|
+
"test-windows": "mocha --timeout=4000",
|
|
31
31
|
"coverage": "nyc report --reporter=text-lcov | coveralls"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|