@@ -148,6 +148,14 @@ export class PackageManagerUtils {
148148 prefix : '--cwd' ,
149149 noLockfile : '' ,
150150 } ;
151+ case PackageManager . Deno :
152+ return {
153+ saveDev : '--dev' ,
154+ install : 'add' ,
155+ installAll : 'install' ,
156+ prefix : '--root' ,
157+ noLockfile : '--no-lock' ,
158+ } ;
151159 default :
152160 return {
153161 saveDev : '--save-dev' ,
@@ -194,7 +202,8 @@ export class PackageManagerUtils {
194202 @memoize
195203 private getVersion ( name : PackageManager ) : string | undefined {
196204 try {
197- return execSync ( `${ name } --version` , {
205+ const versionArg = name !== PackageManager . Deno ? '--version' : '-v' ;
206+ const version = execSync ( `${ name } ${ versionArg } ` , {
198207 encoding : 'utf8' ,
199208 stdio : [ 'ignore' , 'pipe' , 'ignore' ] ,
200209 env : {
@@ -204,6 +213,13 @@ export class PackageManagerUtils {
204213 NPM_CONFIG_UPDATE_NOTIFIER : 'false' ,
205214 } ,
206215 } ) . trim ( ) ;
216+
217+ if ( name === PackageManager . Deno ) {
218+ // Deno CLI outputs "deno 2.4.4"
219+ return version . replace ( 'deno ' , '' ) ;
220+ }
221+
222+ return version ;
207223 } catch {
208224 return undefined ;
209225 }
@@ -220,14 +236,21 @@ export class PackageManagerUtils {
220236 const hasYarnLock = this . hasLockfile ( PackageManager . Yarn ) ;
221237 const hasPnpmLock = this . hasLockfile ( PackageManager . Pnpm ) ;
222238 const hasBunLock = this . hasLockfile ( PackageManager . Bun ) ;
239+ const hasDenoLock = this . hasLockfile ( PackageManager . Deno ) ;
223240
224241 // PERF NOTE: `this.getVersion` spawns the package a the child_process which can take around ~300ms at times.
225242 // Therefore, we should only call this method when needed. IE: don't call `this.getVersion(PackageManager.Pnpm)` unless truly needed.
226243 // The result of this method is not stored in a variable because it's memoized.
227244
228245 if ( hasNpmLock ) {
229246 // Has NPM lock file.
230- if ( ! hasYarnLock && ! hasPnpmLock && ! hasBunLock && this . getVersion ( PackageManager . Npm ) ) {
247+ if (
248+ ! hasYarnLock &&
249+ ! hasPnpmLock &&
250+ ! hasBunLock &&
251+ ! hasDenoLock &&
252+ this . getVersion ( PackageManager . Npm )
253+ ) {
231254 // Only NPM lock file and NPM binary is available.
232255 return PackageManager . Npm ;
233256 }
@@ -242,6 +265,9 @@ export class PackageManagerUtils {
242265 } else if ( hasBunLock && this . getVersion ( PackageManager . Bun ) ) {
243266 // Bun lock file and Bun binary is available.
244267 return PackageManager . Bun ;
268+ } else if ( hasDenoLock && this . getVersion ( PackageManager . Deno ) ) {
269+ // Deno lock file and Deno binary is available.
270+ return PackageManager . Deno ;
245271 }
246272 }
247273
@@ -250,13 +276,16 @@ export class PackageManagerUtils {
250276 const hasYarn = ! ! this . getVersion ( PackageManager . Yarn ) ;
251277 const hasPnpm = ! ! this . getVersion ( PackageManager . Pnpm ) ;
252278 const hasBun = ! ! this . getVersion ( PackageManager . Bun ) ;
279+ const hasDeno = ! ! this . getVersion ( PackageManager . Deno ) ;
253280
254- if ( hasYarn && ! hasPnpm && ! hasBun ) {
281+ if ( hasYarn && ! hasPnpm && ! hasBun && ! hasDeno ) {
255282 return PackageManager . Yarn ;
256- } else if ( hasPnpm && ! hasYarn && ! hasBun ) {
283+ } else if ( hasPnpm && ! hasYarn && ! hasBun && ! hasDeno ) {
257284 return PackageManager . Pnpm ;
258- } else if ( hasBun && ! hasYarn && ! hasPnpm ) {
285+ } else if ( hasBun && ! hasYarn && ! hasPnpm && ! hasDeno ) {
259286 return PackageManager . Bun ;
287+ } else if ( hasDeno && ! hasYarn && ! hasPnpm && ! hasBun ) {
288+ return PackageManager . Deno ;
260289 }
261290 }
262291
@@ -277,6 +306,9 @@ export class PackageManagerUtils {
277306 case PackageManager . Bun :
278307 lockfileName = 'bun.lockb' ;
279308 break ;
309+ case PackageManager . Deno :
310+ lockfileName = 'deno.lock' ;
311+ break ;
280312 case PackageManager . Npm :
281313 default :
282314 lockfileName = 'package-lock.json' ;
0 commit comments