33 * Provides cross-platform bin path lookup, command execution, and path normalization.
44 */
55
6- import { APPDATA } from '#env/appdata'
7- import { HOME } from '#env/home'
8- import { LOCALAPPDATA } from '#env/localappdata'
9- import { XDG_DATA_HOME } from '#env/xdg-data-home'
6+ import { getHome } from '#env/home'
7+ import { getAppdata , getLocalappdata } from '#env/windows'
8+ import { getXdgDataHome } from '#env/xdg'
109
1110import { WIN32 } from '#constants/platform'
1211import { readJsonSync } from './fs'
@@ -259,10 +258,10 @@ export function findRealPnpm(): string {
259258 const commonPaths = WIN32
260259 ? [
261260 // Windows common paths.
262- path ?. join ( APPDATA as string , 'npm' , 'pnpm.cmd' ) ,
263- path ?. join ( APPDATA as string , 'npm' , 'pnpm' ) ,
264- path ?. join ( LOCALAPPDATA as string , 'pnpm' , 'pnpm.cmd' ) ,
265- path ?. join ( LOCALAPPDATA as string , 'pnpm' , 'pnpm' ) ,
261+ path ?. join ( getAppdata ( ) as string , 'npm' , 'pnpm.cmd' ) ,
262+ path ?. join ( getAppdata ( ) as string , 'npm' , 'pnpm' ) ,
263+ path ?. join ( getLocalappdata ( ) as string , 'pnpm' , 'pnpm.cmd' ) ,
264+ path ?. join ( getLocalappdata ( ) as string , 'pnpm' , 'pnpm' ) ,
266265 'C:\\Program Files\\nodejs\\pnpm.cmd' ,
267266 'C:\\Program Files\\nodejs\\pnpm' ,
268267 ] . filter ( Boolean )
@@ -271,10 +270,10 @@ export function findRealPnpm(): string {
271270 '/usr/local/bin/pnpm' ,
272271 '/usr/bin/pnpm' ,
273272 path ?. join (
274- ( XDG_DATA_HOME as string ) || `${ HOME as string } /.local/share` ,
273+ ( getXdgDataHome ( ) as string ) || `${ getHome ( ) as string } /.local/share` ,
275274 'pnpm/pnpm' ,
276275 ) ,
277- path ?. join ( HOME as string , '.pnpm/pnpm' ) ,
276+ path ?. join ( getHome ( ) as string , '.pnpm/pnpm' ) ,
278277 ] . filter ( Boolean )
279278
280279 return findRealBin ( 'pnpm' , commonPaths ) ?? ''
@@ -290,8 +289,11 @@ export function findRealYarn(): string {
290289 const commonPaths = [
291290 '/usr/local/bin/yarn' ,
292291 '/usr/bin/yarn' ,
293- path ?. join ( HOME as string , '.yarn/bin/yarn' ) ,
294- path ?. join ( HOME as string , '.config/yarn/global/node_modules/.bin/yarn' ) ,
292+ path ?. join ( getHome ( ) as string , '.yarn/bin/yarn' ) ,
293+ path ?. join (
294+ getHome ( ) as string ,
295+ '.config/yarn/global/node_modules/.bin/yarn' ,
296+ ) ,
295297 ] . filter ( Boolean )
296298
297299 return findRealBin ( 'yarn' , commonPaths ) ?? ''
@@ -585,7 +587,7 @@ export function resolveBinPathSync(binPath: string): string {
585587
586588 // Handle special case where pnpm path in CI has extra segments.
587589 // In setup-pnpm GitHub Action, the path might be malformed like:
588- // /home/runner /setup-pnpm/node_modules/.bin/pnpm/bin/pnpm.cjs
590+ // /home/user /setup-pnpm/node_modules/.bin/pnpm/bin/pnpm.cjs
589591 // This happens when the shell script contains a relative path that
590592 // when resolved, creates an invalid nested structure.
591593 if ( isPnpmOrYarn && binPath . includes ( '/.bin/pnpm/bin/' ) ) {
0 commit comments