@@ -17,6 +17,7 @@ import {
1717 type PkgJson ,
1818 readJson ,
1919 readTextFile ,
20+ styleText ,
2021 writeJson ,
2122 writeTextFile ,
2223} from "../src/utils.ts" ;
@@ -273,23 +274,21 @@ describe("install", () => {
273274 } ) ;
274275 } ) ;
275276
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+ ) ;
293292 } ) ;
294293
295294 it ( "jsr add -O @std/[email protected] - dev dependency" , async ( ) => { @@ -329,23 +328,21 @@ describe("install", () => {
329328 } ) ;
330329 } ) ;
331330
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+ ) ;
349346 } ) ;
350347
351348 it ( "jsr i - runs '<pkg-manager> install' instead" , async ( ) => {
@@ -435,54 +432,53 @@ describe("install", () => {
435432 } ) ;
436433 } ) ;
437434
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 ) ;
443449 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 " ,
446452 ) ;
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+ } ) ;
447460
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+ } ) ;
486482
487483 describe ( "env detection" , ( ) => {
488484 it ( "detect pnpm from npm_config_user_agent" , async ( ) => {
@@ -579,26 +575,24 @@ describe("install", () => {
579575 } ) ;
580576 } ) ;
581577
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 } ` ,
598592 } ,
599- ) ;
600- } ) ;
601- }
593+ } ,
594+ ) ;
595+ } ) ;
602596 } ) ;
603597} ) ;
604598
@@ -673,8 +667,7 @@ describe("publish", () => {
673667 "export const value = 42;" ,
674668 ) ;
675669
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" ) , {
678671 name : "@deno/jsr-cli-test" ,
679672 version : pkgJson . version ! ,
680673 license : "MIT" ,
@@ -767,8 +760,7 @@ describe("publish", () => {
767760 "export const value = 42;" ,
768761 ) ;
769762
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" ) , {
772764 name : "@deno/jsr-cli-test" ,
773765 version : "1.0.0" ,
774766 license : "MIT" ,
@@ -790,8 +782,7 @@ describe("publish", () => {
790782 "export const value = 42;" ,
791783 ) ;
792784
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" ) , {
795786 name : "@deno/jsr-cli-test" ,
796787 version : "1.0.0" ,
797788 license : "MIT" ,
@@ -871,7 +862,7 @@ describe("show", () => {
871862 true ,
872863 ) ;
873864
874- assert . ok ( output . combined . includes ( "latest: -" ) ) ;
865+ assert . ok ( output . combined . includes ( "latest: " + styleText ( "magenta" , "-" ) ) ) ;
875866 assert . ok ( output . combined . includes ( "npm tarball:" ) ) ;
876867 } ) ;
877868} ) ;
0 commit comments