Skip to content

Commit d08df09

Browse files
committed
Use naturalCompare
1 parent e2cc9e5 commit d08df09

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/utils/package-manager-detector.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import which from 'which'
1010
import { parse as parseBunLockb } from '@socketregistry/hyrious__bun.lockb/index.cjs'
1111
import { isObjectObject } from '@socketsecurity/registry/lib/objects'
1212
import { readPackageJson } from '@socketsecurity/registry/lib/packages'
13+
import { naturalCompare } from '@socketsecurity/registry/lib/sorts'
1314
import { isNonEmptyString } from '@socketsecurity/registry/lib/strings'
1415

1516
import { findUp, readFileBinary, readFileUtf8 } from './fs'
@@ -34,11 +35,6 @@ export const AGENTS = [BUN, NPM, PNPM, YARN_BERRY, YARN_CLASSIC, VLT] as const
3435
export type Agent = (typeof AGENTS)[number]
3536
export type StringKeyValueObject = { [key: string]: string }
3637

37-
const { compare: alphanumericComparator } = new Intl.Collator(undefined, {
38-
numeric: true,
39-
sensitivity: 'base'
40-
})
41-
4238
const binByAgent = {
4339
__proto__: null,
4440
[BUN]: BUN,
@@ -246,7 +242,7 @@ export async function detect({
246242
if (Array.isArray(browserslistQuery)) {
247243
const browserslistTargets = browserslist(browserslistQuery)
248244
.map(s => s.toLowerCase())
249-
.sort(alphanumericComparator)
245+
.sort(naturalCompare)
250246
const browserslistNodeTargets = browserslistTargets
251247
.filter(v => v.startsWith('node '))
252248
.map(v => v.slice(5 /*'node '.length*/))

0 commit comments

Comments
 (0)