Skip to content

Commit cc394fa

Browse files
committed
workaround bun bug
1 parent 9dfef52 commit cc394fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ type Conf = {config: {get: (key: string) => string | undefined}};
220220
let conf: Conf | undefined;
221221
let rat: typeof registryAuthToken | undefined;
222222

223-
async function getRegistry(scope?: string): Promise<string> {
224-
if (!conf) conf = (await import("@pnpm/npm-conf")).default();
223+
function getRegistry(scope?: string): string {
224+
if (!conf) conf = require("@pnpm/npm-conf")(); // eslint-disable-line @typescript-eslint/no-require-imports -- workaround bun bug with import()
225225

226226
let url: string | undefined;
227227
if (scope) {
@@ -240,7 +240,7 @@ async function getAuthAndRegistry(name: string, registry: string): Promise<AuthA
240240
return {auth: rat(registry, {recursive: true}), registry};
241241
} else {
242242
const scope = (/@[a-z0-9][\w-.]+/.exec(name) || [""])[0];
243-
const url = normalizeUrl(await getRegistry(scope));
243+
const url = normalizeUrl(getRegistry(scope));
244244
if (url !== registry) {
245245
try {
246246
const newAuth = rat(url, {recursive: true});
@@ -292,7 +292,7 @@ type PackageInfo = [Record<string, any>, string, string | null, string];
292292

293293
async function fetchNpmInfo(name: string, type: string, config: Config): Promise<PackageInfo> {
294294
const originalRegistry = normalizeUrl((typeof args.registry === "string" ? args.registry : false) ||
295-
config.registry || (await getRegistry()),
295+
config.registry || getRegistry(),
296296
);
297297

298298
const {auth, registry} = await getAuthAndRegistry(name, originalRegistry);

0 commit comments

Comments
 (0)