Skip to content

Commit

Permalink
refactor: make functions async
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jan 30, 2022
1 parent 7104e34 commit 8f9d2a2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/utils/resolveId.ts
Expand Up @@ -45,15 +45,18 @@ export async function resolveId(
);
}

function addJsExtensionIfNecessary(file: string, preserveSymlinks: boolean): string | undefined {
async function addJsExtensionIfNecessary(
file: string,
preserveSymlinks: boolean
): Promise<string | undefined> {
return (
findFile(file, preserveSymlinks) ??
findFile(file + '.mjs', preserveSymlinks) ??
findFile(file + '.js', preserveSymlinks)
(await findFile(file, preserveSymlinks)) ??
(await findFile(file + '.mjs', preserveSymlinks)) ??
(await findFile(file + '.js', preserveSymlinks))
);
}

function findFile(file: string, preserveSymlinks: boolean): string | undefined {
async function findFile(file: string, preserveSymlinks: boolean): Promise<string | undefined> {
try {
const stats = lstatSync(file);
if (!preserveSymlinks && stats.isSymbolicLink())
Expand Down

0 comments on commit 8f9d2a2

Please sign in to comment.