Merge pull request #109 from samuelthomas2774/add-unix-node-sass-build-scripts

Add node-sass build scripts for macOS and Linux
This commit is contained in:
Alexei Stukov 2018-02-11 18:30:01 +02:00 committed by GitHub
commit 1db9ad3425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 1 deletions

View File

@ -33,6 +33,7 @@
"gulp-watch": "^5.0.0",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"node-gyp": "^3.6.2",
"node-sass": "^4.7.2",
"pump": "^2.0.0",
"sass-loader": "^6.0.6",
@ -49,6 +50,7 @@
"watch_client": "npm run watch --prefix client",
"watch_core": "npm run watch --prefix core",
"lint": "eslint -f unix client/src core/src csseditor/src",
"test": "npm run build && npm run lint"
"test": "npm run build && npm run lint",
"build_node-sass": "node scripts/build-node-sass.js"
}
}

View File

@ -0,0 +1,8 @@
#!/bin/sh
PLATFORM="darwin"
ARCH="x64"
NODE_API_VERSION="53"
ELECTRON_VERSION="1.6.15"
scripts/build-node-sass.sh $PLATFORM $ARCH $NODE_API_VERSION $ELECTRON_VERSION

View File

@ -0,0 +1,8 @@
#!/bin/sh
PLATFORM="linux"
ARCH="x64"
NODE_API_VERSION="53"
ELECTRON_VERSION="1.6.15"
scripts/build-node-sass.sh $PLATFORM $ARCH $NODE_API_VERSION $ELECTRON_VERSION

View File

@ -0,0 +1,19 @@
const process = require('process');
const child_process = require('child_process');
switch (process.platform) {
case 'darwin':
case 'linux':
child_process.execSync(`scripts/build-node-sass-${process.platform}.sh`, {
stdio: 'inherit'
});
break;
case 'win32':
child_process.execSync(`scripts/rebuild-node-sass.bat`, {
stdio: 'inherit'
});
break;
default:
console.log(`Unknown platform ${process.platform}`);
process.exit(1);
}

32
scripts/build-node-sass.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
PLATFORM="$1"
ARCH="$2"
NODE_API_VERSION="$3"
ELECTRON_VERSION="$4"
ELECTRON_URL="https://atom.io/download/electron"
DIRECTORY="vendor/$PLATFORM-$ARCH-$NODE_API_VERSION"
if [ `node -p 'process.platform'` != "$PLATFORM" ]; then
echo "You must be running on $PLATFORM to build node-sass for it."
exit 1
fi
cd node_modules/node-sass
if [ -f $DIRECTORY/binding.node ]; then
echo "A binding already exists at $DIRECTORY/binding.node - deleting it"
rm $DIRECTORY/binding.node
fi
# Build the node-sass binding
# This will be placed at build/Release/binding.node
echo "Building node-sass for $PLATFORM-$ARCH with Node.js API version $NODE_API_VERSION for Electron $ELECTRON_VERSION"
../.bin/node-gyp rebuild --target=$ELECTRON_VERSION --arch $ARCH --dist-url=$ELECTRON_URL
# Move it to the right place
echo "Moving binding.node to $DIRECTORY"
mkdir -p $DIRECTORY
cp build/Release/binding.node $DIRECTORY/binding.node
rm -rf build