-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Sass executable wrapper that forwards to the correct exe
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
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash -e | ||
|
||
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" | ||
if [ "$(basename "$dir")" == bin ]; then | ||
# Global executables are installed in .../bin/, and global libraries | ||
# (including their dependencies) in .../lib/node_modules. | ||
node_modules="$(dirname "$dir")/lib/node_modules" | ||
elif [ "$(basename "$dir")" == .bin ]; then | ||
# Local dependency executables are installed in ./node_modules/.bin, and | ||
# and their libraries in ./node_modules. | ||
node_modules="$(dirname "$dir")" | ||
else | ||
# If all else fails, try to find node_modules in a parent directory. We | ||
# might execute this, for example, if someone runs the script from source. | ||
while [ "$dir" != "/" ]; do | ||
dir="$(dirname "$dir")" | ||
if [ -d "$dir/node_modules" ]; then | ||
node_modules="$dir/node_modules" | ||
break | ||
fi | ||
done | ||
echo "Could not find node_modules above ${BASH_SOURCE[0]}!" >&2 | ||
exit 1 | ||
fi | ||
|
||
case "$(uname -s)" in | ||
Linux*) | ||
if [ ! -z "$ANDROID_ROOT" -a ! -z "$ANDROID_DATA" ]; then | ||
os=android | ||
else | ||
os=linux | ||
fi;; | ||
Darwin*) | ||
os=darwin;; | ||
CYGWIN*|MINGW*|MSYS_NT*) | ||
os=win32;; | ||
*) | ||
echo "Unknown operating system $(uname -s)!" >&2 | ||
exit 1 | ||
esac | ||
|
||
musl= | ||
if [ "$os" == linux ] && grep -q /ld-musl- /bin/bash; then musl=-musl; fi | ||
|
||
case "$(uname -m)" in | ||
aarch64*) arch=arm64;; | ||
arm*) arch=arm;; | ||
x86_64) arch=x64;; | ||
i386|i486|i586|i686) arch=ia32;; | ||
*) | ||
echo "Unknown architecture $(uname -m)!" >&2 | ||
exit 1 | ||
esac | ||
|
||
shared="$node_modules/sass-embedded-$os$musl-$arch" | ||
specific="$node_modules/sass-embedded/node_modules/sass-embedded-$os$musl-$arch" | ||
if [ -d "$specific" ]; then | ||
exec "$specific/dart-sass/sass" "$@" | ||
else | ||
exec "$shared/dart-sass/sass" "$@" | ||
fi | ||
|
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