Skip to content

Commit e1ee873

Browse files
committed
fix: simplify getConfigPath
1 parent 95b0ba1 commit e1ee873

1 file changed

Lines changed: 5 additions & 16 deletions

File tree

src/config.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,14 @@ import { hotUrlRegistrys, registryKeys, registrys } from "./constant.ts";
66
async function getConfigPath(local?: boolean) {
77
const rc = ".npmrc";
88

9-
if (local === true) {
10-
return rc;
11-
}
12-
13-
const hasLocalRc = await exists(rc, { isFile: true });
14-
15-
if (!hasLocalRc) {
9+
if (local === undefined) {
10+
if (await exists(rc, { isFile: true })) {
11+
return rc;
12+
}
1613
return getHomeDirRc();
1714
}
1815

19-
const hasLocalRcRegistry = await Deno.readTextFile(rc).then((text) => {
20-
return text.includes("registry");
21-
});
22-
23-
if (hasLocalRcRegistry) {
24-
return rc;
25-
}
26-
27-
return getHomeDirRc();
16+
return local ? rc : getHomeDirRc();
2817

2918
function getHomeDirRc() {
3019
return `${homedir().replaceAll("\\", "/")}/${rc}`;

0 commit comments

Comments
 (0)