Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/lucky-lands-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"biome": minor
---

Resolve biome.cmd from PATH on Windows
4 changes: 2 additions & 2 deletions src/biome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type WorkspaceFolder,
workspace,
} from "vscode";
import { platformSpecificBinaryName } from "./constants";
import { platformSpecificDefaultBinaryName } from "./constants";
import type Extension from "./extension";
import Locator from "./locator";
import Logger from "./logger";
Expand Down Expand Up @@ -348,7 +348,7 @@ export default class Biome {

const destination = Uri.joinPath(
tempDirectory,
platformSpecificBinaryName,
platformSpecificDefaultBinaryName,
);

this.logger.debug(
Expand Down
22 changes: 20 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ export const platformIdentifier = (() => {
return `${process.platform}-${process.arch}${flavor}`;
})();

/**
* Platform-specific binary names
*
* This constant contains the possible names of the Biome binary for the current
* platform. On Windows, both "biome.exe" and "biome.cmd" are possible names for
* the binary, depending on how it was installed.
*
* @example "biome" (on Linux, macOS, and other Unix-like systems)
* @example ["biome.exe", "biome.cmd"] (on Windows)
*/
export const platformSpecificBinaryNames = (() => {
if (process.platform === "win32") {
return ["biome.exe", "biome.cmd"];
}

return ["biome"];
})();

/**
* Platform-specific binary name
*
Expand All @@ -72,8 +90,8 @@ export const platformIdentifier = (() => {
* @example "biome" (on Linux, macOS, and other Unix-like systems)
* @example "biome.exe" (on Windows)
*/
export const platformSpecificBinaryName = (() => {
return `biome${process.platform === "win32" ? ".exe" : ""}`;
export const platformSpecificDefaultBinaryName = (() => {
return platformSpecificBinaryNames[0];
})();

/**
Expand Down
21 changes: 12 additions & 9 deletions src/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { Utils } from "vscode-uri";
import type Biome from "./biome";
import {
platformIdentifier,
platformSpecificBinaryName,
platformSpecificBinaryNames,
platformSpecificDefaultBinaryName,
platformSpecificNodePackageName,
} from "./constants";
import {
Expand Down Expand Up @@ -324,7 +325,7 @@ export default class Locator {
// Resolve the path to the biome binary.
const biome = Uri.joinPath(
pathToBiomeCliPackage,
platformSpecificBinaryName,
platformSpecificDefaultBinaryName,
);

if (await fileExists(biome)) {
Expand Down Expand Up @@ -396,7 +397,7 @@ export default class Locator {

const biome = Uri.file(
yarnPnpApi.resolveRequest(
`${platformSpecificNodePackageName}/${platformSpecificBinaryName}`,
`${platformSpecificNodePackageName}/${platformSpecificDefaultBinaryName}`,
rootBiomePackage,
) as string,
);
Expand Down Expand Up @@ -430,12 +431,14 @@ export default class Locator {
}

for (const dir of path.split(delimiter)) {
const biome = Uri.joinPath(Uri.file(dir), platformSpecificBinaryName);
if (await fileExists(biome)) {
this.biome.logger.debug(
`🔍 Found Biome binary at "${biome.fsPath}" in PATH`,
);
return biome;
for (const binaryName of platformSpecificBinaryNames) {
const biome = Uri.joinPath(Uri.file(dir), binaryName);
if (await fileExists(biome)) {
this.biome.logger.debug(
`🔍 Found Biome binary at "${biome.fsPath}" in PATH`,
);
return biome;
}
}
}

Expand Down
Loading