Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
fix(add): Specify 'en' locale to String.localeCompare (#3)
Browse files Browse the repository at this point in the history
No test added, since there's nothing in this module that particularly
depends on string sorting, but it's a best practice all the same.

Re: npm/cli#2829
  • Loading branch information
isaacs authored May 10, 2021
1 parent 43b1c07 commit 7d185c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/cache-install-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const cacheInstallDir = ({ cache, packages }) => {

const getHash = (packages) =>
crypto.createHash('sha512')
.update(packages.sort((a, b) => a.localeCompare(b)).join('\n'))
.update(packages.sort((a, b) => a.localeCompare(b, 'en')).join('\n'))
.digest('hex')
.slice(0, 16)

Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const exec = async (opts) => {
},
}))
.map(mani => mani._from)
.sort((a, b) => a.localeCompare(b))
.sort((a, b) => a.localeCompare(b, 'en'))

// no need to install if already present
if (add.length) {
Expand Down

0 comments on commit 7d185c3

Please sign in to comment.