Skip to content

Commit 9eb7fc4

Browse files
committed
Add YARN constant
1 parent ae99d38 commit 9eb7fc4

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/constants.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type Constants = {
3434
readonly SOCKET_CLI_ISSUES_URL: 'https://github.com/SocketDev/socket-cli/issues'
3535
readonly SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE: 'SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE'
3636
readonly VLT: 'vlt'
37+
readonly YARN: 'yarn'
3738
readonly YARN_BERRY: 'yarn/berry'
3839
readonly YARN_CLASSIC: 'yarn/classic'
3940
readonly cdxgenBinPath: string
@@ -71,8 +72,9 @@ const SOCKET_CLI_ISSUES_URL = 'https://github.com/SocketDev/socket-cli/issues'
7172
const SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE =
7273
'SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE'
7374
const VLT = 'vlt'
74-
const YARN_BERRY = 'yarn/berry'
75-
const YARN_CLASSIC = 'yarn/classic'
75+
const YARN = 'yarn'
76+
const YARN_BERRY = `${YARN}/berry`
77+
const YARN_CLASSIC = `${YARN}/classic`
7678

7779
const LAZY_DIST_TYPE = () =>
7880
registryConstants.SUPPORTS_NODE_REQUIRE_MODULE ? MODULE_SYNC : REQUIRE
@@ -145,6 +147,7 @@ const constants = <Constants>createConstantsObject(
145147
SOCKET_CLI_ISSUES_URL,
146148
SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE,
147149
VLT,
150+
YARN,
148151
YARN_BERRY,
149152
YARN_CLASSIC,
150153
cdxgenBinPath: undefined,

src/utils/package-manager-detector.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const {
2424
NPM,
2525
PNPM,
2626
VLT,
27+
YARN,
2728
YARN_BERRY,
2829
YARN_CLASSIC
2930
} = constants
@@ -32,21 +33,21 @@ export const AGENTS = [BUN, NPM, PNPM, YARN_BERRY, YARN_CLASSIC, VLT] as const
3233
export type Agent = (typeof AGENTS)[number]
3334
export type StringKeyValueObject = { [key: string]: string }
3435

36+
const { compare: alphanumericComparator } = new Intl.Collator(undefined, {
37+
numeric: true,
38+
sensitivity: 'base'
39+
})
40+
3541
const binByAgent = {
3642
__proto__: null,
3743
[BUN]: BUN,
3844
[NPM]: NPM,
3945
[PNPM]: PNPM,
40-
[YARN_BERRY]: 'yarn',
41-
[YARN_CLASSIC]: 'yarn',
46+
[YARN_BERRY]: YARN,
47+
[YARN_CLASSIC]: YARN,
4248
[VLT]: VLT
4349
}
4450

45-
const { compare: alphanumericComparator } = new Intl.Collator(undefined, {
46-
numeric: true,
47-
sensitivity: 'base'
48-
})
49-
5051
async function getAgentExecPath(agent: Agent): Promise<string> {
5152
const binName = binByAgent[agent]
5253
return (await which(binName, { nothrow: true })) ?? binName

0 commit comments

Comments
 (0)