Comparing version 2.1.0 to 3.0.0
24
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
const defaultOpts = {spawn: true}; | ||
const defaultOptions = {spawn: true}; | ||
const defaultLocale = 'en_US'; | ||
@@ -24,4 +24,4 @@ | ||
function getLocale(str) { | ||
return (str && str.replace(/[.:].*/, '')); | ||
function getLocale(string) { | ||
return (string && string.replace(/[.:].*/, '')); | ||
} | ||
@@ -63,3 +63,3 @@ | ||
function getWinLocaleSync() { | ||
const stdout = execa.sync('wmic', ['os', 'get', 'locale']).stdout; | ||
const {stdout} = execa.sync('wmic', ['os', 'get', 'locale']); | ||
const lcidCode = parseInt(stdout.replace('Locale', ''), 16); | ||
@@ -69,8 +69,7 @@ return lcid.from(lcidCode); | ||
module.exports = mem(opts => { | ||
opts = opts || defaultOpts; | ||
module.exports = mem((options = defaultOptions) => { | ||
const envLocale = getEnvLocale(); | ||
let thenable; | ||
if (envLocale || opts.spawn === false) { | ||
if (envLocale || options.spawn === false) { | ||
thenable = Promise.resolve(getLocale(envLocale)); | ||
@@ -87,8 +86,7 @@ } else if (process.platform === 'win32') { | ||
module.exports.sync = mem(opts => { | ||
opts = opts || defaultOpts; | ||
module.exports.sync = mem((options = defaultOptions) => { | ||
const envLocale = getEnvLocale(); | ||
let res; | ||
if (envLocale || opts.spawn === false) { | ||
if (envLocale || options.spawn === false) { | ||
res = getLocale(envLocale); | ||
@@ -102,3 +100,3 @@ } else { | ||
} | ||
} catch (err) {} | ||
} catch (_) {} | ||
} | ||
@@ -105,0 +103,0 @@ |
{ | ||
"name": "os-locale", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Get the system locale", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=6" | ||
}, | ||
@@ -37,5 +37,5 @@ "scripts": { | ||
"dependencies": { | ||
"execa": "^0.7.0", | ||
"lcid": "^1.0.0", | ||
"mem": "^1.1.0" | ||
"execa": "^0.10.0", | ||
"lcid": "^2.0.0", | ||
"mem": "^3.0.1" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
@@ -13,3 +13,3 @@ # os-locale [![Build Status](https://travis-ci.org/sindresorhus/os-locale.svg?branch=master)](https://travis-ci.org/sindresorhus/os-locale) | ||
``` | ||
$ npm install --save os-locale | ||
$ npm install os-locale | ||
``` | ||
@@ -23,6 +23,6 @@ | ||
osLocale().then(locale => { | ||
console.log(locale); | ||
(async () => { | ||
console.log(await osLocale()); | ||
//=> 'en_US' | ||
}); | ||
})(); | ||
``` | ||
@@ -29,0 +29,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5229
81
+ Addedcross-spawn@6.0.5(transitive)
+ Addedexeca@0.10.0(transitive)
+ Addedinvert-kv@2.0.0(transitive)
+ Addedlcid@2.0.0(transitive)
+ Addedmem@3.0.1(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addedp-is-promise@1.1.0(transitive)
+ Addedsemver@5.7.2(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removedexeca@0.7.0(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedlcid@1.0.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmem@1.1.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedyallist@2.1.2(transitive)
Updatedexeca@^0.10.0
Updatedlcid@^2.0.0
Updatedmem@^3.0.1