Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: remove unnecessary tryResolveId
  • Loading branch information
JounQin committed Mar 7, 2024
commit a0c5c233f3d1c22dc7ffaa7906e83218919a57e8
16 changes: 1 addition & 15 deletions @commitlint/resolve-extends/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function resolveConfig(
raw: string,
context: ResolveExtendsContext = {}
): string {
const resolve = context.resolve || tryResolveId;
const resolve = context.resolve || resolveId;
const id = getId(raw, context.prefix);

let resolved: string;
Expand All @@ -194,20 +194,6 @@ function resolveConfig(
return resolved;
}

function tryResolveId(id: string, context: ResolveExtendsContext) {
const cwd = context.cwd || process.cwd();

for (const suffix of ['', '.js', '.json', '/index.js', '/index.json']) {
try {
return fileURLToPath(
moduleResolve(id + suffix, pathToFileURL(path.join(cwd, id)))
);
} catch {}
}

return resolveId(id, context);
}

function resolveId(
specifier: string,
context: ResolveExtendsContext = {}
Expand Down