-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcompiler-module.ts
34 lines (29 loc) · 1022 Bytes
/
compiler-module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2025 Google LLC. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import * as p from 'path';
import {getElfInterpreter} from './elf';
/**
* Detect if the given binary is linked with musl libc by checking if
* the interpreter basename starts with "ld-musl-"
*/
function isLinuxMusl(path: string): boolean {
try {
const interpreter = getElfInterpreter(path);
return p.basename(interpreter).startsWith('ld-musl-');
} catch (error) {
console.warn(
`Warning: Failed to detect linux-musl, fallback to linux-gnu: ${error.message}`,
);
return false;
}
}
/** The module name for the embedded compiler executable. */
export const compilerModule = (() => {
const platform =
process.platform === 'linux' && isLinuxMusl(process.execPath)
? 'linux-musl'
: (process.platform as string);
const arch = process.arch;
return `sass-embedded-${platform}-${arch}`;
})();