Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

os-locale

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

os-locale - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

47

index.js

@@ -9,2 +9,10 @@ 'use strict';

async function getStdOut(command, args) {
return (await execa(command, args)).stdout;
}
function getStdOutSync(command, args) {
return execa.sync(command, args).stdout;
}
function getEnvLocale(env = process.env) {

@@ -29,7 +37,7 @@ return env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE;

async function getLocales() {
return execa.stdout('locale', ['-a']);
return getStdOut('locale', ['-a']);
}
function getLocalesSync() {
return execa.sync('locale', ['-a']).stdout;
return getStdOutSync('locale', ['-a']);
}

@@ -43,3 +51,3 @@

const results = await Promise.all([
execa.stdout('defaults', ['read', '-globalDomain', 'AppleLocale']),
getStdOut('defaults', ['read', '-globalDomain', 'AppleLocale']),
getLocales()

@@ -53,3 +61,3 @@ ]);

return getSupportedLocale(
execa.sync('defaults', ['read', '-globalDomain', 'AppleLocale']).stdout,
getStdOutSync('defaults', ['read', '-globalDomain', 'AppleLocale']),
getLocalesSync()

@@ -60,20 +68,13 @@ );

async function getUnixLocale() {
if (process.platform === 'darwin') {
return getAppleLocale();
}
return getLocale(parseLocale(await execa.stdout('locale')));
return getLocale(parseLocale(await getStdOut('locale')));
}
function getUnixLocaleSync() {
if (process.platform === 'darwin') {
return getAppleLocaleSync();
}
return getLocale(parseLocale(execa.sync('locale').stdout));
return getLocale(parseLocale(getStdOutSync('locale')));
}
async function getWinLocale() {
const stdout = await execa.stdout('wmic', ['os', 'get', 'locale']);
const stdout = await getStdOut('wmic', ['os', 'get', 'locale']);
const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
return lcid.from(lcidCode);

@@ -83,9 +84,15 @@ }

function getWinLocaleSync() {
const {stdout} = execa.sync('wmic', ['os', 'get', 'locale']);
const stdout = getStdOutSync('wmic', ['os', 'get', 'locale']);
const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
return lcid.from(lcidCode);
}
function normalise(input) {
return input.replace(/_/, '-');
}
const osLocale = mem(async (options = defaultOptions) => {
let locale;
try {

@@ -98,2 +105,4 @@ const envLocale = getEnvLocale();

locale = await getWinLocale();
} else if (process.platform === 'darwin') {
locale = await getAppleLocale();
} else {

@@ -104,3 +113,3 @@ locale = await getUnixLocale();

return (locale || defaultLocale).replace(/_/, '-');
return normalise(locale || defaultLocale);
}, {cachePromiseRejection: false});

@@ -119,2 +128,4 @@

locale = getWinLocaleSync();
} else if (process.platform === 'darwin') {
locale = getAppleLocaleSync();
} else {

@@ -125,3 +136,3 @@ locale = getUnixLocaleSync();

return (locale || defaultLocale).replace(/_/, '-');
return normalise(locale || defaultLocale);
});
{
"name": "os-locale",
"version": "4.0.0",
"version": "5.0.0",
"description": "Get the system locale",
"license": "MIT",
"repository": "sindresorhus/os-locale",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=10"
},

@@ -37,3 +38,3 @@ "scripts": {

"dependencies": {
"execa": "^1.0.0",
"execa": "^4.0.0",
"lcid": "^3.0.0",

@@ -44,6 +45,6 @@ "mem": "^5.0.0"

"ava": "^2.1.0",
"import-fresh": "^3.0.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"proxyquire": "^2.1.3",
"tsd": "^0.11.0",
"xo": "^0.28.0"
}
}

@@ -9,3 +9,2 @@ # os-locale [![Build Status](https://travis-ci.org/sindresorhus/os-locale.svg?branch=master)](https://travis-ci.org/sindresorhus/os-locale)

## Install

@@ -17,3 +16,2 @@

## Usage

@@ -29,4 +27,2 @@

```
## API

@@ -44,7 +40,7 @@

Type: `Object`
Type: `object`
##### spawn
Type: `boolean`<br>
Type: `boolean`\
Default: `true`

@@ -54,13 +50,6 @@

## os-locale for enterprise
---
Available as part of the Tidelift Subscription.
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-os-locale?utm_source=npm-os-locale&utm_medium=referral&utm_campaign=readme">Get professional support for 'os-locale' with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
The maintainers of os-locale and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-os-locale?utm_source=npm-os-locale&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc