Skip to content

Commit 987bfcf

Browse files
committed
Fix yarn detection
1 parent 377b80a commit 987bfcf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/utils/package-manager-detector.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,24 @@ export const AGENTS = [BUN, NPM, PNPM, YARN_BERRY, YARN_CLASSIC, VLT] as const
3232
export type Agent = (typeof AGENTS)[number]
3333
export type StringKeyValueObject = { [key: string]: string }
3434

35+
const binByAgent = {
36+
__proto__: null,
37+
[BUN]: BUN,
38+
[NPM]: NPM,
39+
[PNPM]: PNPM,
40+
[YARN_BERRY]: 'yarn',
41+
[YARN_CLASSIC]: 'yarn',
42+
[VLT]: VLT
43+
}
44+
3545
const { compare: alphanumericComparator } = new Intl.Collator(undefined, {
3646
numeric: true,
3747
sensitivity: 'base'
3848
})
3949

4050
async function getAgentExecPath(agent: Agent): Promise<string> {
41-
return (await which(agent, { nothrow: true })) ?? agent
51+
const binName = binByAgent[agent]
52+
return (await which(binName, { nothrow: true })) ?? binName
4253
}
4354

4455
async function getAgentVersion(

0 commit comments

Comments
 (0)