File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export async function setupNpmRc(dir: string) {
2828 const msg = `Setting up ${ NPMRC_FILE } ` ;
2929 try {
3030 let content = await fs . promises . readFile ( npmRcPath , "utf-8" ) ;
31- if ( ! content . includes ( JSR_NPMRC ) ) {
31+ if ( ! content . includes ( "@jsr:registry=" ) ) {
3232 content += JSR_NPMRC ;
3333 await wrapWithStatus ( msg , async ( ) => {
3434 await fs . promises . writeFile ( npmRcPath , content ) ;
Original file line number Diff line number Diff line change 1+ import * as path from "path" ;
2+ import * as fs from "fs" ;
3+ import { runInTempDir } from "./test_utils" ;
4+ import { setupNpmRc } from "../src/commands" ;
5+ import * as assert from "assert/strict" ;
6+
7+ describe ( "npmrc" , ( ) => {
8+ it ( "doesn't overwrite exising jsr mapping" , async ( ) => {
9+ await runInTempDir ( async ( dir ) => {
10+ const npmrc = path . join ( dir , ".npmrc" ) ;
11+ await fs . promises . writeFile (
12+ npmrc ,
13+ "@jsr:registry=https://example.com\n" ,
14+ "utf-8" ,
15+ ) ;
16+
17+ await setupNpmRc ( dir ) ;
18+
19+ const content = await fs . promises . readFile ( npmrc , "utf-8" ) ;
20+ assert . equal ( content . trim ( ) , "@jsr:registry=https://example.com" ) ;
21+ } ) ;
22+ } ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments