@@ -141,6 +141,14 @@ export class PackageManagerUtils {
141
141
prefix : '--prefix' ,
142
142
noLockfile : '--no-lockfile' ,
143
143
} ;
144
+ case PackageManager . Bun :
145
+ return {
146
+ saveDev : '--development' ,
147
+ install : 'add' ,
148
+ installAll : 'install' ,
149
+ prefix : '--cwd' ,
150
+ noLockfile : '' ,
151
+ } ;
144
152
default :
145
153
return {
146
154
saveDev : '--save-dev' ,
@@ -218,14 +226,15 @@ export class PackageManagerUtils {
218
226
const hasNpmLock = this . hasLockfile ( PackageManager . Npm ) ;
219
227
const hasYarnLock = this . hasLockfile ( PackageManager . Yarn ) ;
220
228
const hasPnpmLock = this . hasLockfile ( PackageManager . Pnpm ) ;
229
+ const hasBunLock = this . hasLockfile ( PackageManager . Bun ) ;
221
230
222
231
// PERF NOTE: `this.getVersion` spawns the package a the child_process which can take around ~300ms at times.
223
232
// Therefore, we should only call this method when needed. IE: don't call `this.getVersion(PackageManager.Pnpm)` unless truly needed.
224
233
// The result of this method is not stored in a variable because it's memoized.
225
234
226
235
if ( hasNpmLock ) {
227
236
// Has NPM lock file.
228
- if ( ! hasYarnLock && ! hasPnpmLock && this . getVersion ( PackageManager . Npm ) ) {
237
+ if ( ! hasYarnLock && ! hasPnpmLock && ! hasBunLock && this . getVersion ( PackageManager . Npm ) ) {
229
238
// Only NPM lock file and NPM binary is available.
230
239
return PackageManager . Npm ;
231
240
}
@@ -237,18 +246,24 @@ export class PackageManagerUtils {
237
246
} else if ( hasPnpmLock && this . getVersion ( PackageManager . Pnpm ) ) {
238
247
// PNPM lock file and PNPM binary is available.
239
248
return PackageManager . Pnpm ;
249
+ } else if ( hasBunLock && this . getVersion ( PackageManager . Bun ) ) {
250
+ // Bun lock file and Bun binary is available.
251
+ return PackageManager . Bun ;
240
252
}
241
253
}
242
254
243
255
if ( ! this . getVersion ( PackageManager . Npm ) ) {
244
256
// Doesn't have NPM installed.
245
257
const hasYarn = ! ! this . getVersion ( PackageManager . Yarn ) ;
246
258
const hasPnpm = ! ! this . getVersion ( PackageManager . Pnpm ) ;
259
+ const hasBun = ! ! this . getVersion ( PackageManager . Bun ) ;
247
260
248
- if ( hasYarn && ! hasPnpm ) {
261
+ if ( hasYarn && ! hasPnpm && ! hasBun ) {
249
262
return PackageManager . Yarn ;
250
- } else if ( ! hasYarn && hasPnpm ) {
263
+ } else if ( hasPnpm && ! hasYarn && ! hasBun ) {
251
264
return PackageManager . Pnpm ;
265
+ } else if ( hasBun && ! hasYarn && ! hasPnpm ) {
266
+ return PackageManager . Bun ;
252
267
}
253
268
}
254
269
@@ -266,6 +281,9 @@ export class PackageManagerUtils {
266
281
case PackageManager . Pnpm :
267
282
lockfileName = 'pnpm-lock.yaml' ;
268
283
break ;
284
+ case PackageManager . Bun :
285
+ lockfileName = 'bun.lockb' ;
286
+ break ;
269
287
case PackageManager . Npm :
270
288
default :
271
289
lockfileName = 'package-lock.json' ;
0 commit comments