@@ -141,6 +141,14 @@ export class PackageManagerUtils {
141141 prefix : '--prefix' ,
142142 noLockfile : '--no-lockfile' ,
143143 } ;
144+ case PackageManager . Bun :
145+ return {
146+ saveDev : '--development' ,
147+ install : 'add' ,
148+ installAll : 'install' ,
149+ prefix : '--cwd' ,
150+ noLockfile : '' ,
151+ } ;
144152 default :
145153 return {
146154 saveDev : '--save-dev' ,
@@ -218,14 +226,15 @@ export class PackageManagerUtils {
218226 const hasNpmLock = this . hasLockfile ( PackageManager . Npm ) ;
219227 const hasYarnLock = this . hasLockfile ( PackageManager . Yarn ) ;
220228 const hasPnpmLock = this . hasLockfile ( PackageManager . Pnpm ) ;
229+ const hasBunLock = this . hasLockfile ( PackageManager . Bun ) ;
221230
222231 // PERF NOTE: `this.getVersion` spawns the package a the child_process which can take around ~300ms at times.
223232 // Therefore, we should only call this method when needed. IE: don't call `this.getVersion(PackageManager.Pnpm)` unless truly needed.
224233 // The result of this method is not stored in a variable because it's memoized.
225234
226235 if ( hasNpmLock ) {
227236 // Has NPM lock file.
228- if ( ! hasYarnLock && ! hasPnpmLock && this . getVersion ( PackageManager . Npm ) ) {
237+ if ( ! hasYarnLock && ! hasPnpmLock && ! hasBunLock && this . getVersion ( PackageManager . Npm ) ) {
229238 // Only NPM lock file and NPM binary is available.
230239 return PackageManager . Npm ;
231240 }
@@ -237,18 +246,24 @@ export class PackageManagerUtils {
237246 } else if ( hasPnpmLock && this . getVersion ( PackageManager . Pnpm ) ) {
238247 // PNPM lock file and PNPM binary is available.
239248 return PackageManager . Pnpm ;
249+ } else if ( hasBunLock && this . getVersion ( PackageManager . Bun ) ) {
250+ // Bun lock file and Bun binary is available.
251+ return PackageManager . Bun ;
240252 }
241253 }
242254
243255 if ( ! this . getVersion ( PackageManager . Npm ) ) {
244256 // Doesn't have NPM installed.
245257 const hasYarn = ! ! this . getVersion ( PackageManager . Yarn ) ;
246258 const hasPnpm = ! ! this . getVersion ( PackageManager . Pnpm ) ;
259+ const hasBun = ! ! this . getVersion ( PackageManager . Bun ) ;
247260
248- if ( hasYarn && ! hasPnpm ) {
261+ if ( hasYarn && ! hasPnpm && ! hasBun ) {
249262 return PackageManager . Yarn ;
250- } else if ( ! hasYarn && hasPnpm ) {
263+ } else if ( hasPnpm && ! hasYarn && ! hasBun ) {
251264 return PackageManager . Pnpm ;
265+ } else if ( hasBun && ! hasYarn && ! hasPnpm ) {
266+ return PackageManager . Bun ;
252267 }
253268 }
254269
@@ -266,6 +281,9 @@ export class PackageManagerUtils {
266281 case PackageManager . Pnpm :
267282 lockfileName = 'pnpm-lock.yaml' ;
268283 break ;
284+ case PackageManager . Bun :
285+ lockfileName = 'bun.lockb' ;
286+ break ;
269287 case PackageManager . Npm :
270288 default :
271289 lockfileName = 'package-lock.json' ;
0 commit comments