Skip to content

Commit b6bf128

Browse files
authored
Merge branch 'main' into rm-redirect
2 parents 6a8a791 + dad6bb4 commit b6bf128

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

packages/cli/src/resolve-lint.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ export async function lint(): Promise<{
4545
// On Windows, try .exe first (bun creates .exe), then .cmd (npm/pnpm/yarn create .cmd)
4646
const scriptDir = dirname(fileURLToPath(import.meta.url));
4747
const localBinDir = join(scriptDir, '..', 'node_modules', '.bin');
48-
const cwdBinDir = join(process.cwd(), 'node_modules', '.bin');
49-
oxlintTsgolintPath =
50-
[
51-
join(localBinDir, 'tsgolint.exe'),
52-
join(localBinDir, 'tsgolint.cmd'),
53-
join(cwdBinDir, 'tsgolint.exe'),
54-
join(cwdBinDir, 'tsgolint.cmd'),
55-
].find((p) => existsSync(p)) ?? '';
48+
const oxlintTsgolintPackagePath = dirname(dirname(oxlintTsgolintPath));
49+
const projectBinDir = join(oxlintTsgolintPackagePath, '..', '.bin');
50+
const pathCandidates = [
51+
join(localBinDir, 'tsgolint.exe'),
52+
join(localBinDir, 'tsgolint.cmd'),
53+
join(projectBinDir, 'tsgolint.exe'),
54+
join(projectBinDir, 'tsgolint.cmd'),
55+
];
56+
oxlintTsgolintPath = pathCandidates.find((p) => existsSync(p)) ?? '';
5657
// Bun stores packages in .bun/ cache dirs where the symlinked paths above won't match.
5758
if (!oxlintTsgolintPath) {
5859
try {
@@ -67,7 +68,10 @@ export async function lint(): Promise<{
6768
}
6869
}
6970
if (!oxlintTsgolintPath) {
70-
oxlintTsgolintPath = join(cwdBinDir, 'tsgolint.cmd');
71+
throw new Error(
72+
'Unable to resolve oxlint-tsgolint executable, tried:\n' +
73+
pathCandidates.map((path) => `- ${path}`).join('\n'),
74+
);
7175
}
7276
const relativePath = relative(process.cwd(), oxlintTsgolintPath);
7377
// Only prepend .\ if it's actually a relative path (not an absolute path returned by relative())

0 commit comments

Comments
 (0)