Skip to content

Commit

Permalink
Remove broken launcher config from optional dependencies' package.json (
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme authored Aug 1, 2024
1 parent 9b5f08b commit 53abf98
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 81 deletions.
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

0 comments on commit 53abf98

Please sign in to comment.