Skip to content

Commit

Permalink
refactor: clarty
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 18, 2024
1 parent 1dae31d commit e1a6614
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,18 @@ export function defineEnv(opts: CreateEnvOptions = {}): {
url: resolvePaths,
};

const _resolve = (id: string) => {
const _tryResolve = (id: string) => {
try {
return resolvePathSync(id, resolveOpts);
} catch {
if (id.startsWith("unenv/")) {
try {
return resolvePathSync(
id.replace("unenv/", "unenv-nightly/"),
resolveOpts,
);
} catch {}
}
} catch {}
};

const _resolve = (id: string) => {
let resolved = _tryResolve(id);
if (!resolved && id.startsWith("unenv/")) {
resolved = _tryResolve(id.replace("unenv/", "unenv-nightly/"));
}
return id;
return resolved || id;
};

// Resolve aliases
Expand Down

0 comments on commit e1a6614

Please sign in to comment.