diff options
author | isaacs <i@izs.me> | 2021-09-28 21:18:01 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2021-09-28 21:52:07 +0300 |
commit | dbb90f7997900b8ae6026dddaa718efe9a1db2f4 (patch) | |
tree | 2241c89f49fa3d8291d0123ce52026e6cbe088d4 /lib/utils/completion/installed-deep.js | |
parent | e94ddeaca1e75ecc8f54ebcb3df222965e3635d1 (diff) |
fix: use Intl.Collator for string sorting when availableisaacs/string-locale-compare
The npm/cli form of https://github.com/npm/arborist/pull/324
Required adding options support to package used for this.
PR-URL: https://github.com/npm/cli/pull/3809
Credit: @isaacs
Close: #3809
Reviewed-by: @wraithgar
Diffstat (limited to 'lib/utils/completion/installed-deep.js')
-rw-r--r-- | lib/utils/completion/installed-deep.js | 4 |
1 files changed, 2 insertions, 2 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, '..') }) |