Skip to content

Commit

Permalink
fix: add linux-musl target in bin/biome
Browse files Browse the repository at this point in the history
  • Loading branch information
matteosacchetto committed Dec 5, 2023
1 parent 367e2a2 commit f4ff180
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/@biomejs/biome/bin/biome
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env node
const { platform, arch, env, version, release } = process;
const { execSync } = require("child_process");

function isMusl() {
let stderr;
try {
stderr = execSync("ldd --version", {
stdio: ['pipe', 'pipe', 'pipe']
});
} catch (err) {
stderr = err.stderr;
}
if (stderr.indexOf("musl") > -1) {
return true;
}
return false;
}

const PLATFORMS = {
win32: {
Expand All @@ -14,12 +30,21 @@ const PLATFORMS = {
x64: "@biomejs/cli-linux-x64/biome",
arm64: "@biomejs/cli-linux-arm64/biome",
},
"linux-musl": {
x64: "@biomejs/cli-linux-x64-musl/biome",
arm64: "@biomejs/cli-linux-arm64-musl/biome",
},
};
if (env.ROME_BINARY) {
console.warn(`[WARN] The environment variable "ROME_BINARY" is deprecated. Use "BIOME_BINARY" instead.`)
}

const binPath = env.BIOME_BINARY || env.ROME_BINARY || PLATFORMS?.[platform]?.[arch];
const binPath = env.BIOME_BINARY || env.ROME_BINARY ||
(platform === "linux" && isMusl()
? PLATFORMS?.["linux-musl"]?.[arch]
: PLATFORMS?.[platform]?.[arch]
);

if (binPath) {
const packageManager = detectPackageManager();
const result = require("child_process").spawnSync(
Expand Down

0 comments on commit f4ff180

Please sign in to comment.