From 66c102edf44038b74c26f86d134e8b215987f78c Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 6 May 2021 14:41:33 -0700 Subject: [PATCH] force 'en' locale in string sorting Re: https://github.com/npm/cli/issues/2829 --- common.js | 10 ++-------- glob.js | 2 -- sync.js | 2 -- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/common.js b/common.js index 66651bb3..d14157a0 100644 --- a/common.js +++ b/common.js @@ -1,5 +1,3 @@ -exports.alphasort = alphasort -exports.alphasorti = alphasorti exports.setopts = setopts exports.ownProp = ownProp exports.makeAbs = makeAbs @@ -17,12 +15,8 @@ var minimatch = require("minimatch") var isAbsolute = require("path-is-absolute") var Minimatch = minimatch.Minimatch -function alphasorti (a, b) { - return a.toLowerCase().localeCompare(b.toLowerCase()) -} - function alphasort (a, b) { - return a.localeCompare(b) + return a.localeCompare(b, 'en') } function setupIgnores (self, options) { @@ -150,7 +144,7 @@ function finish (self) { all = Object.keys(all) if (!self.nosort) - all = all.sort(self.nocase ? alphasorti : alphasort) + all = all.sort(alphasort) // at *some* point we statted all of these if (self.mark) { diff --git a/glob.js b/glob.js index 58dec0f6..dc27aef1 100644 --- a/glob.js +++ b/glob.js @@ -51,8 +51,6 @@ var assert = require('assert') var isAbsolute = require('path-is-absolute') var globSync = require('./sync.js') var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp var inflight = require('inflight') diff --git a/sync.js b/sync.js index c952134b..10b0ed2c 100644 --- a/sync.js +++ b/sync.js @@ -11,8 +11,6 @@ var path = require('path') var assert = require('assert') var isAbsolute = require('path-is-absolute') var common = require('./common.js') -var alphasort = common.alphasort -var alphasorti = common.alphasorti var setopts = common.setopts var ownProp = common.ownProp var childrenIgnored = common.childrenIgnored