Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/completion/installed-deep.js4
-rw-r--r--lib/utils/config/describe-all.js3
-rw-r--r--lib/utils/npm-usage.js3
-rw-r--r--lib/utils/tar.js11
4 files changed, 11 insertions, 10 deletions
diff --git a/lib/utils/completion/installed-deep.js b/lib/utils/completion/installed-deep.js
index 243068861..590955a1e 100644
--- a/lib/utils/completion/installed-deep.js
+++ b/lib/utils/completion/installed-deep.js
@@ -1,5 +1,6 @@
const { resolve } = require('path')
const Arborist = require('@npmcli/arborist')
+const localeCompare = require('@isaacs/string-locale-compare')('en')
const installedDeep = async (npm) => {
const {
@@ -15,8 +16,7 @@ const installedDeep = async (npm) => {
return i
})
.filter(i => (i.depth - 1) <= depth)
- .sort((a, b) => a.depth - b.depth)
- .sort((a, b) => a.depth === b.depth ? a.name.localeCompare(b.name, 'en') : 0)
+ .sort((a, b) => (a.depth - b.depth) || localeCompare(a.name, b.name))
const res = new Set()
const gArb = new Arborist({ global: true, path: resolve(npm.globalDir, '..') })
diff --git a/lib/utils/config/describe-all.js b/lib/utils/config/describe-all.js
index c8a973cc0..23a10ae97 100644
--- a/lib/utils/config/describe-all.js
+++ b/lib/utils/config/describe-all.js
@@ -1,4 +1,5 @@
const definitions = require('./definitions.js')
+const localeCompare = require('@isaacs/string-locale-compare')('en')
const describeAll = () => {
// sort not-deprecated ones to the top
/* istanbul ignore next - typically already sorted in the definitions file,
@@ -7,7 +8,7 @@ const describeAll = () => {
const sort = ([keya, {deprecated: depa}], [keyb, {deprecated: depb}]) => {
return depa && !depb ? 1
: !depa && depb ? -1
- : keya.localeCompare(keyb, 'en')
+ : localeCompare(keya, keyb)
}
return Object.entries(definitions).sort(sort)
.map(([key, def]) => def.describe())
diff --git a/lib/utils/npm-usage.js b/lib/utils/npm-usage.js
index ddb0bab0b..f6785867c 100644
--- a/lib/utils/npm-usage.js
+++ b/lib/utils/npm-usage.js
@@ -1,5 +1,6 @@
const { dirname } = require('path')
const { cmdList } = require('./cmd-list')
+const localeCompare = require('@isaacs/string-locale-compare')('en')
module.exports = (npm) => {
const usesBrowser = npm.config.get('viewer') === 'browser'
@@ -62,7 +63,7 @@ const usages = (npm) => {
maxLen = Math.max(maxLen, c.length)
return set
}, [])
- .sort((a, b) => a[0].localeCompare(b[0], 'en'))
+ .sort(([a], [b]) => localeCompare(a, b))
.map(([c, usage]) => `\n ${c}${' '.repeat(maxLen - c.length + 1)}${
(usage.split('\n').join('\n' + ' '.repeat(maxLen + 5)))}`)
.join('\n')
diff --git a/lib/utils/tar.js b/lib/utils/tar.js
index c3071c1bd..0ff822370 100644
--- a/lib/utils/tar.js
+++ b/lib/utils/tar.js
@@ -3,6 +3,10 @@ const ssri = require('ssri')
const npmlog = require('npmlog')
const formatBytes = require('./format-bytes.js')
const columnify = require('columnify')
+const localeCompare = require('@isaacs/string-locale-compare')('en', {
+ sensitivity: 'case',
+ numeric: true,
+})
const logTar = (tarball, opts = {}) => {
const { unicode = false, log = npmlog } = opts
@@ -75,12 +79,7 @@ const getContents = async (manifest, tarball) => {
algorithms: ['sha1', 'sha512'],
})
- const comparator = (a, b) => {
- return a.path.localeCompare(b.path, 'en', {
- sensitivity: 'case',
- numeric: true,
- })
- }
+ const comparator = ({ path: a }, { path: b }) => localeCompare(a, b)
const isUpper = (str) => {
const ch = str.charAt(0)