@@ -17,6 +17,7 @@ import {
17
17
type PkgJson ,
18
18
readJson ,
19
19
readTextFile ,
20
+ styleText ,
20
21
writeJson ,
21
22
writeTextFile ,
22
23
} from "../src/utils.ts" ;
@@ -273,23 +274,21 @@ describe("install", () => {
273
274
} ) ;
274
275
} ) ;
275
276
276
- if ( process . platform !== "win32" ) {
277
- await withTempEnv (
278
- [ "i" , "--bun" , "--save-dev" , "@std/[email protected] " ] ,
279
- async ( dir ) => {
280
- assert . ok (
281
- await isFile ( path . join ( dir , "bun.lock" ) ) ,
282
- "bun lockfile not created" ,
283
- ) ;
284
- const pkgJson = await readJson < PkgJson > (
285
- path . join ( dir , "package.json" ) ,
286
- ) ;
287
- assert . deepEqual ( pkgJson . devDependencies , {
288
- "@std/encoding" :
"npm:@jsr/[email protected] " ,
289
- } ) ;
290
- } ,
291
- ) ;
292
- }
277
+ await withTempEnv (
278
+ [ "i" , "--bun" , "--save-dev" , "@std/[email protected] " ] ,
279
+ async ( dir ) => {
280
+ assert . ok (
281
+ await isFile ( path . join ( dir , "bun.lock" ) ) ,
282
+ "bun lockfile not created" ,
283
+ ) ;
284
+ const pkgJson = await readJson < PkgJson > (
285
+ path . join ( dir , "package.json" ) ,
286
+ ) ;
287
+ assert . deepEqual ( pkgJson . devDependencies , {
288
+ "@std/encoding" :
"npm:@jsr/[email protected] " ,
289
+ } ) ;
290
+ } ,
291
+ ) ;
293
292
} ) ;
294
293
295
294
it ( "jsr add -O @std/[email protected] - dev dependency" , async ( ) => {
@@ -329,23 +328,21 @@ describe("install", () => {
329
328
} ) ;
330
329
} ) ;
331
330
332
- if ( process . platform !== "win32" ) {
333
- await withTempEnv (
334
- [ "i" , "--bun" , "--save-optional" , "@std/[email protected] " ] ,
335
- async ( dir ) => {
336
- assert . ok (
337
- await isFile ( path . join ( dir , "bun.lock" ) ) ,
338
- "bun lockfile not created" ,
339
- ) ;
340
- const pkgJson = await readJson < PkgJson > (
341
- path . join ( dir , "package.json" ) ,
342
- ) ;
343
- assert . deepEqual ( pkgJson . optionalDependencies , {
344
- "@std/encoding" :
"npm:@jsr/[email protected] " ,
345
- } ) ;
346
- } ,
347
- ) ;
348
- }
331
+ await withTempEnv (
332
+ [ "i" , "--bun" , "--save-optional" , "@std/[email protected] " ] ,
333
+ async ( dir ) => {
334
+ assert . ok (
335
+ await isFile ( path . join ( dir , "bun.lock" ) ) ,
336
+ "bun lockfile not created" ,
337
+ ) ;
338
+ const pkgJson = await readJson < PkgJson > (
339
+ path . join ( dir , "package.json" ) ,
340
+ ) ;
341
+ assert . deepEqual ( pkgJson . optionalDependencies , {
342
+ "@std/encoding" :
"npm:@jsr/[email protected] " ,
343
+ } ) ;
344
+ } ,
345
+ ) ;
349
346
} ) ;
350
347
351
348
it ( "jsr i - runs '<pkg-manager> install' instead" , async ( ) => {
@@ -435,54 +432,53 @@ describe("install", () => {
435
432
} ) ;
436
433
} ) ;
437
434
438
- if ( process . platform !== "win32" ) {
439
- it ( "jsr add --bun @std/[email protected] - forces bun" , async ( ) => {
440
- await withTempEnv (
441
- [ "i" , "--bun" , "@std/[email protected] " ] ,
442
- async ( dir ) => {
435
+ it ( "jsr add --bun @std/[email protected] - forces bun" , async ( ) => {
436
+ await withTempEnv (
437
+ [ "i" , "--bun" , "@std/[email protected] " ] ,
438
+ async ( dir ) => {
439
+ assert . ok (
440
+ await isFile ( path . join ( dir , "bun.lock" ) ) ,
441
+ "bun lockfile not created" ,
442
+ ) ;
443
+
444
+ const bun = new Bun ( dir ) ;
445
+
446
+ if ( await bun . isNpmrcSupported ( ) ) {
447
+ const npmrcPath = path . join ( dir , ".npmrc" ) ;
448
+ const npmRc = await readTextFile ( npmrcPath ) ;
443
449
assert . ok (
444
- await isFile ( path . join ( dir , "bun.lock" ) ) ,
445
- "bun lockfile not created " ,
450
+ npmRc . includes ( "@jsr:registry=https://npm.jsr.io" ) ,
451
+ "Missing npmrc registry " ,
446
452
) ;
453
+ } else {
454
+ const config = await readTextFile ( path . join ( dir , "bunfig.toml" ) ) ;
455
+ assert . match ( config , / " @ j s r " \s + = / , "bunfig.toml not created" ) ;
456
+ }
457
+ } ,
458
+ ) ;
459
+ } ) ;
447
460
448
- const bun = new Bun ( dir ) ;
449
-
450
- if ( await bun . isNpmrcSupported ( ) ) {
451
- const npmrcPath = path . join ( dir , ".npmrc" ) ;
452
- const npmRc = await readTextFile ( npmrcPath ) ;
453
- assert . ok (
454
- npmRc . includes ( "@jsr:registry=https://npm.jsr.io" ) ,
455
- "Missing npmrc registry" ,
456
- ) ;
457
- } else {
458
- const config = await readTextFile ( path . join ( dir , "bunfig.toml" ) ) ;
459
- assert . match ( config , / " @ j s r " \s + = / , "bunfig.toml not created" ) ;
460
- }
461
- } ,
462
- ) ;
463
- } ) ;
464
- it ( "jsr add --bun @std/[email protected] - forces bun for twice" , async ( ) => {
465
- await withTempEnv (
466
- [ "i" , "--bun" , "@std/[email protected] " ] ,
467
- async ( dir ) => {
468
- await runJsr ( [ "i" , "--bun" , "@std/[email protected] " ] , dir ) ;
469
-
470
- const bun = new Bun ( dir ) ;
471
- if ( await bun . isNpmrcSupported ( ) ) {
472
- const npmrcPath = path . join ( dir , ".npmrc" ) ;
473
- const npmRc = await readTextFile ( npmrcPath ) ;
474
- assert . ok (
475
- npmRc . includes ( "@jsr:registry=https://npm.jsr.io" ) ,
476
- "Missing npmrc registry" ,
477
- ) ;
478
- } else {
479
- const config = await readTextFile ( path . join ( dir , "bunfig.toml" ) ) ;
480
- assert . match ( config , / " @ j s r " \s + = / , "bunfig.toml not created" ) ;
481
- }
482
- } ,
483
- ) ;
484
- } ) ;
485
- }
461
+ it ( "jsr add --bun @std/[email protected] - forces bun for twice" , async ( ) => {
462
+ await withTempEnv (
463
+ [ "i" , "--bun" , "@std/[email protected] " ] ,
464
+ async ( dir ) => {
465
+ await runJsr ( [ "i" , "--bun" , "@std/[email protected] " ] , dir ) ;
466
+
467
+ const bun = new Bun ( dir ) ;
468
+ if ( await bun . isNpmrcSupported ( ) ) {
469
+ const npmrcPath = path . join ( dir , ".npmrc" ) ;
470
+ const npmRc = await readTextFile ( npmrcPath ) ;
471
+ assert . ok (
472
+ npmRc . includes ( "@jsr:registry=https://npm.jsr.io" ) ,
473
+ "Missing npmrc registry" ,
474
+ ) ;
475
+ } else {
476
+ const config = await readTextFile ( path . join ( dir , "bunfig.toml" ) ) ;
477
+ assert . match ( config , / " @ j s r " \s + = / , "bunfig.toml not created" ) ;
478
+ }
479
+ } ,
480
+ ) ;
481
+ } ) ;
486
482
487
483
describe ( "env detection" , ( ) => {
488
484
it ( "detect pnpm from npm_config_user_agent" , async ( ) => {
@@ -579,26 +575,24 @@ describe("install", () => {
579
575
} ) ;
580
576
} ) ;
581
577
582
- if ( process . platform !== "win32" ) {
583
- it ( "detect bun from npm_config_user_agent" , async ( ) => {
584
- await withTempEnv (
585
-
586
- async ( dir ) => {
587
- assert . ok (
588
- await isFile ( path . join ( dir , "bun.lock" ) ) ,
589
- "bun lockfile not created" ,
590
- ) ;
591
- } ,
592
- {
593
- env : {
594
- ...process . env ,
595
- npm_config_user_agent :
596
- `bun/1.0.29 ${ process . env . npm_config_user_agent } ` ,
597
- } ,
578
+ it ( "detect bun from npm_config_user_agent" , async ( ) => {
579
+ await withTempEnv (
580
+
581
+ async ( dir ) => {
582
+ assert . ok (
583
+ await isFile ( path . join ( dir , "bun.lock" ) ) ,
584
+ "bun lockfile not created" ,
585
+ ) ;
586
+ } ,
587
+ {
588
+ env : {
589
+ ...process . env ,
590
+ npm_config_user_agent :
591
+ `bun/1.0.29 ${ process . env . npm_config_user_agent } ` ,
598
592
} ,
599
- ) ;
600
- } ) ;
601
- }
593
+ } ,
594
+ ) ;
595
+ } ) ;
602
596
} ) ;
603
597
} ) ;
604
598
@@ -673,8 +667,7 @@ describe("publish", () => {
673
667
"export const value = 42;" ,
674
668
) ;
675
669
676
- // TODO: Change this once deno supports jsr.json
677
- await writeJson < DenoJson > ( path . join ( dir , "deno.json" ) , {
670
+ await writeJson < DenoJson > ( path . join ( dir , "jsr.json" ) , {
678
671
name : "@deno/jsr-cli-test" ,
679
672
version : pkgJson . version ! ,
680
673
license : "MIT" ,
@@ -767,8 +760,7 @@ describe("publish", () => {
767
760
"export const value = 42;" ,
768
761
) ;
769
762
770
- // TODO: Change this once deno supports jsr.json
771
- await writeJson < DenoJson > ( path . join ( dir , "deno.json" ) , {
763
+ await writeJson < DenoJson > ( path . join ( dir , "jsr.json" ) , {
772
764
name : "@deno/jsr-cli-test" ,
773
765
version : "1.0.0" ,
774
766
license : "MIT" ,
@@ -790,8 +782,7 @@ describe("publish", () => {
790
782
"export const value = 42;" ,
791
783
) ;
792
784
793
- // TODO: Change this once deno supports jsr.json
794
- await writeJson < DenoJson > ( path . join ( dir , "deno.json" ) , {
785
+ await writeJson < DenoJson > ( path . join ( dir , "jsr.json" ) , {
795
786
name : "@deno/jsr-cli-test" ,
796
787
version : "1.0.0" ,
797
788
license : "MIT" ,
@@ -871,7 +862,7 @@ describe("show", () => {
871
862
true ,
872
863
) ;
873
864
874
- assert . ok ( output . combined . includes ( "latest: -" ) ) ;
865
+ assert . ok ( output . combined . includes ( "latest: " + styleText ( "magenta" , "-" ) ) ) ;
875
866
assert . ok ( output . combined . includes ( "npm tarball:" ) ) ;
876
867
} ) ;
877
868
} ) ;
0 commit comments