From e1ee8730b70b609cfd6ee25306f2f64967eb89fd Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Sun, 27 Oct 2024 15:18:04 +0800 Subject: [PATCH] fix: simplify getConfigPath --- src/config.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/config.ts b/src/config.ts index 78c1d95..af66440 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,25 +6,14 @@ import { hotUrlRegistrys, registryKeys, registrys } from "./constant.ts"; async function getConfigPath(local?: boolean) { const rc = ".npmrc"; - if (local === true) { - return rc; - } - - const hasLocalRc = await exists(rc, { isFile: true }); - - if (!hasLocalRc) { + if (local === undefined) { + if (await exists(rc, { isFile: true })) { + return rc; + } return getHomeDirRc(); } - const hasLocalRcRegistry = await Deno.readTextFile(rc).then((text) => { - return text.includes("registry"); - }); - - if (hasLocalRcRegistry) { - return rc; - } - - return getHomeDirRc(); + return local ? rc : getHomeDirRc(); function getHomeDirRc() { return `${homedir().replaceAll("\\", "/")}/${rc}`;