Skip to content
Merged
Changes from all commits
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
22 changes: 13 additions & 9 deletions packages/cli/src/resolve-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ export async function lint(): Promise<{
// On Windows, try .exe first (bun creates .exe), then .cmd (npm/pnpm/yarn create .cmd)
const scriptDir = dirname(fileURLToPath(import.meta.url));
const localBinDir = join(scriptDir, '..', 'node_modules', '.bin');
const cwdBinDir = join(process.cwd(), 'node_modules', '.bin');
oxlintTsgolintPath =
[
join(localBinDir, 'tsgolint.exe'),
join(localBinDir, 'tsgolint.cmd'),
join(cwdBinDir, 'tsgolint.exe'),
join(cwdBinDir, 'tsgolint.cmd'),
].find((p) => existsSync(p)) ?? '';
const oxlintTsgolintPackagePath = dirname(dirname(oxlintTsgolintPath));
const projectBinDir = join(oxlintTsgolintPackagePath, '..', '.bin');
const pathCandidates = [
join(localBinDir, 'tsgolint.exe'),
join(localBinDir, 'tsgolint.cmd'),
join(projectBinDir, 'tsgolint.exe'),
join(projectBinDir, 'tsgolint.cmd'),
];
oxlintTsgolintPath = pathCandidates.find((p) => existsSync(p)) ?? '';
// Bun stores packages in .bun/ cache dirs where the symlinked paths above won't match.
if (!oxlintTsgolintPath) {
try {
Expand All @@ -67,7 +68,10 @@ export async function lint(): Promise<{
}
}
if (!oxlintTsgolintPath) {
oxlintTsgolintPath = join(cwdBinDir, 'tsgolint.cmd');
throw new Error(
'Unable to resolve oxlint-tsgolint executable, tried:\n' +
pathCandidates.map((path) => `- ${path}`).join('\n'),
);
}
const relativePath = relative(process.cwd(), oxlintTsgolintPath);
// Only prepend .\ if it's actually a relative path (not an absolute path returned by relative())
Expand Down
Loading