-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
sass --embedded
in pure JS mode
- Loading branch information
Showing
7 changed files
with
106 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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}`; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters