Skip to content

Commit

Permalink
Add a Sass executable wrapper that forwards to the correct exe (#313)
Browse files Browse the repository at this point in the history
This allows users to run `npx sass` when they've just installed
`sass-embedded` and directly run the Dart VM. Due to npm/cmd-shim#152,
there's no way to make this work on Windows CMD/Powershell without
substantially curtailing the performance on other operating systems.
  • Loading branch information
nex3 authored Aug 1, 2024
1 parent 53abf98 commit 0093f68
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 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;
}
}
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
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 0093f68

Please sign in to comment.