File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -287,7 +287,9 @@ export async function run(
287
287
}
288
288
289
289
if ( ! options . prefix ) {
290
- options . prefix = await packageManagers [ options . packageManager === 'yarn' ? 'yarn' : 'npm' ] . defaultPrefix ! ( options )
290
+ const defaultPrefix =
291
+ packageManagers [ options . packageManager || 'npm' ] . defaultPrefix || packageManagers . npm . defaultPrefix !
292
+ options . prefix = await defaultPrefix ( options )
291
293
}
292
294
293
295
let timeout : NodeJS . Timeout | undefined
Original file line number Diff line number Diff line change 1
1
import { Options } from 'pacote'
2
+ import path from 'path'
2
3
import spawn from 'spawn-please'
3
4
import keyValueBy from '../lib/keyValueBy'
4
5
import programError from '../lib/programError'
@@ -28,6 +29,18 @@ async function spawnBun(
28
29
29
30
return spawn ( 'bun' , fullArgs , spawnOptions )
30
31
}
32
+
33
+ /** Returns the global directory of bun. */
34
+ export const defaultPrefix = async ( options : Options ) : Promise < string > => {
35
+ if ( options . prefix ) {
36
+ return options . prefix
37
+ } else if ( process . env . BUN_INSTALL ) {
38
+ return process . env . BUN_INSTALL
39
+ }
40
+ const bin = await spawn ( 'bun' , [ 'pm' , '-g' , 'bin' ] )
41
+ return path . dirname ( bin )
42
+ }
43
+
31
44
/**
32
45
* (Bun) Fetches the list of all installed packages.
33
46
*/
You can’t perform that action at this time.
0 commit comments