diff options
author | isaacs <i@izs.me> | 2021-05-07 02:06:29 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-05-10 19:37:12 +0300 |
commit | 1d092144eaaabff63ac8424b40b2286822be7677 (patch) | |
tree | cfc63a6d91736f3165fcc4d38431ff3a2819b660 /scripts/bundle-and-gitignore-deps.js | |
parent | 1eb7e5c7d466293b472c2506c64e5a89ec84ac2f (diff) |
fix(packages): locale-agnostic string sorting
This adds the 'en' locale to all instances of String.localeCompare
within the CLI codebase.
Tests added for the cases where we're sorting arbitrary user-generated
data. The tests rely on the fact that 'ch' sorts after 'd' in the
`'sk'` locale, but ahead of `'d'` in the `'en'` locale. To ensure that
this is the default behavior if no locale is specified, `LC_ALL=sk` is
set in the test environment.
Other instances of `localeCompare` sort data that the cli controls, so
no tests were added.
Re: https://github.com/npm/cli/issues/2829
PR-URL: https://github.com/npm/cli/pull/3203
Credit: @isaacs
Close: #3203
Reviewed-by: @ruyadorno
Diffstat (limited to 'scripts/bundle-and-gitignore-deps.js')
-rw-r--r-- | scripts/bundle-and-gitignore-deps.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/bundle-and-gitignore-deps.js b/scripts/bundle-and-gitignore-deps.js index 0aedec781..691deb916 100644 --- a/scripts/bundle-and-gitignore-deps.js +++ b/scripts/bundle-and-gitignore-deps.js @@ -18,9 +18,9 @@ arb.loadVirtual().then(tree => { bundle.push(node.name) } } - pkg.bundleDependencies = bundle.sort((a, b) => a.localeCompare(b)) + pkg.bundleDependencies = bundle.sort((a, b) => a.localeCompare(b, 'en')) - const ignores = shouldIgnore.sort((a, b) => a.localeCompare(b)) + const ignores = shouldIgnore.sort((a, b) => a.localeCompare(b, 'en')) .map(i => `/${i}`) .join('\n') const ignoreData = `# Automatically generated to ignore dev deps |