Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove broken launcher config from optional dependencies' package.json #322

Merged
merged 1 commit into from
Aug 1, 2024
Merged
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
3 changes: 0 additions & 3 deletions npm/android-arm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/android-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/android-ia32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/android-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"android"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"darwin"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"darwin"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/linux-arm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"linux"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/linux-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"linux"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/linux-ia32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"linux"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/linux-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass"
},
"os": [
"linux"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/win32-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass.bat"
},
"os": [
"win32"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/win32-ia32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass.bat"
},
"os": [
"win32"
],
Expand Down
3 changes: 0 additions & 3 deletions npm/win32-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=14.0.0"
},
"bin": {
"sass": "./dart-sass/sass.bat"
},
"os": [
"win32"
],
Expand Down
42 changes: 0 additions & 42 deletions tool/prepare-optional-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,47 +112,6 @@ async function downloadRelease(options: {
await fs.unlink(zippedAssetPath);
}

// Patch the launcher script if needed.
//
// For linux both `-linux-` and `-linux-musl-` packages will be installed
// because npm doesn't know how to select packages based on LibC. To avoid
// conflicts, only the `-linux-` packages have "bin" scripts defined in
// package.json, which we patch to detect which LibC is available and launch the
// correct binary.
async function patchLauncherScript(
path: string,
dartPlatform: DartPlatform,
dartArch: DartArch
) {
if (dartPlatform !== 'linux') return;

const scriptPath = p.join(path, 'dart-sass', 'sass');
console.log(`Patching ${scriptPath} script.`);

const shebang = Buffer.from('#!/bin/sh\n');
const buffer = await fs.readFile(scriptPath);
if (!buffer.subarray(0, shebang.length).equals(shebang)) {
throw new Error(`${scriptPath} is not a shell script!`);
}

const lines = buffer.toString('utf-8').split('\n');
const index = lines.findIndex(line => line.startsWith('path='));
if (index < 0) {
throw new Error(`The format of ${scriptPath} has changed!`);
}

lines.splice(
index + 1,
0,
'# Detect linux-musl',
'if grep -qm 1 /ld-musl- /proc/self/exe; then',
` path="$path/../../sass-embedded-linux-musl-${dartArch}/dart-sass"`,
'fi'
);

await fs.writeFile(scriptPath, lines.join('\n'));
}

void (async () => {
try {
const version = pkg['compiler-version'] as string;
Expand All @@ -178,7 +137,6 @@ void (async () => {
`${getArchiveExtension(dartPlatform)}`,
outPath,
});
await patchLauncherScript(outPath, dartPlatform, dartArch);
} catch (error) {
console.error(error);
process.exitCode = 1;
Expand Down
Loading