From cea1df517051e69e13745339c1622f26f49af479 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Fri, 23 Feb 2024 14:19:40 +0100 Subject: [PATCH] chore: add more debug logs for npmrc --- src/commands.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands.ts b/src/commands.ts index 1e66fdc..8b6792e 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -1,22 +1,27 @@ import * as path from "node:path"; import * as fs from "node:fs"; import * as kl from "kolorist"; -import { JsrPackage } from "./utils"; +import { JsrPackage, logDebug } from "./utils"; import { getPkgManager } from "./pkg_manager"; const JSR_NPMRC = `@jsr:registry=https://npm.jsr.io\n`; export async function setupNpmRc(dir: string) { const npmRcPath = path.join(dir, ".npmrc"); + logDebug(`Checking for .npmrc at: ${npmRcPath}`); try { let content = await fs.promises.readFile(npmRcPath, "utf-8"); if (!content.includes(JSR_NPMRC)) { content += JSR_NPMRC; await fs.promises.writeFile(npmRcPath, content); + logDebug(`Added @jsr registry to .npmrc`); + } else { + logDebug(`Added @jsr registry already mapped in .npmrc, skipping`); } } catch (err) { if (err instanceof Error && (err as any).code === "ENOENT") { await fs.promises.writeFile(npmRcPath, JSR_NPMRC); + logDebug(`Create new .npmrc file with @jsr registry mapping`); } else { throw err; }