Skip to content

Commit 357a2d3

Browse files
committed
fix(linter): add support for tsgolint.exe on Windows (#14101)
- closes #13784 On Windows, we will search for `tsgolint.CMD` and `tsgolint.exe` before giving up. On other platforms, we will only look for a `tsgolint` executable file.
1 parent 1472147 commit 357a2d3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

crates/oxc_linter/src/tsgolint.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,16 +775,23 @@ pub fn try_find_tsgolint_executable(cwd: &Path) -> Result<PathBuf, String> {
775775
));
776776
}
777777

778-
// executing a sub command in windows, needs a `cmd` or `ps1` extension.
779-
// `cmd` is the most compatible one with older systems
780-
let file = if cfg!(windows) { "tsgolint.CMD" } else { "tsgolint" };
778+
// Executing a sub-command in Windows needs a `cmd` or `ps1` extension.
779+
// Since `cmd` is the most compatible one with older systems, we use that one first,
780+
// then check for `exe` which is also common. Bun, for example, does not create a `cmd`
781+
// file but still produces an `exe` file (https://github.com/oxc-project/oxc/issues/13784).
782+
#[cfg(windows)]
783+
let files = &["tsgolint.CMD", "tsgolint.exe"];
784+
#[cfg(not(windows))]
785+
let files = &["tsgolint"];
781786

782787
// Move upwards until we find a `package.json`, then look at `node_modules/.bin/tsgolint`
783788
let mut current_dir = cwd.to_path_buf();
784789
loop {
785-
let node_modules_bin = current_dir.join("node_modules").join(".bin").join(file);
786-
if node_modules_bin.exists() {
787-
return Ok(node_modules_bin);
790+
for file in files {
791+
let node_modules_bin = current_dir.join("node_modules").join(".bin").join(file);
792+
if node_modules_bin.exists() {
793+
return Ok(node_modules_bin);
794+
}
788795
}
789796

790797
// If we reach the root directory, stop searching

0 commit comments

Comments
 (0)