Skip to content

Commit

Permalink
Merge branch 'main' into new-lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 authored Aug 1, 2024
2 parents ff35c8a + 0093f68 commit 04eb258
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 81 deletions.
25 changes: 25 additions & 0 deletions bin/sass.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node

import * as child_process from 'child_process';
import {compilerCommand} from '../lib/src/compiler-path';

// TODO npm/cmd-shim#152 and yarnpkg/berry#6422 - If and when the package
// managers support it, we should make this a proper shell script rather than a
// JS wrapper.

try {
child_process.execFileSync(
compilerCommand[0],
[...compilerCommand.slice(1), ...process.argv.slice(2)],
{
stdio: 'inherit',
windowsHide: true,
}
);
} catch (error) {
if (error.code) {
throw error;
} else {
process.exitCode = error.status;
}
}
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"engines": {
"node": ">=16.0.0"
},
"bin": {"sass": "dist/bin/sass.js"},
"scripts": {
"init": "ts-node ./tool/init.ts",
"check": "npm-run-all check:gts check:tsc",
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
): Promise<void> {
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
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"exclude": [
"jest.config.js",
"lib/src/vendor/dart-sass/**",
"**/*.test.ts"
]
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"include": [
"*.ts",
"bin/*.ts",
"lib/**/*.ts",
"tool/**/*.ts",
"test/**/*.ts"
Expand Down

0 comments on commit 04eb258

Please sign in to comment.