Make use of node-binary to install node after npm install

This commit is contained in:
Juan Cruz Viotti 2015-02-13 14:47:23 -04:00
parent e23c9f1384
commit 1400ec30e0
4 changed files with 14 additions and 8 deletions

View File

@ -4,6 +4,8 @@ function unsupported_platform() {
echo "Your platform (`uname -a`) is not supported." && exit 1
}
NODE_VERSION="v0.12.0"
# Detect CPU arch.
ARCHITECTURE=`uname -m`
case "$ARCHITECTURE" in
@ -15,19 +17,19 @@ esac
# Darwin
if [ "`uname`" == "Darwin" ]; then
NODE_BIN="node-darwin-$ARCHITECTURE.bin"
NODE_BIN="node-$NODE_VERSION-darwin-$ARCHITECTURE"
# Linux
elif [ "`expr substr $(uname -s) 1 5`" == "Linux" ]; then
NODE_BIN="node-linux-$ARCHITECTURE.bin"
NODE_BIN="node-$NODE_VERSION-linux-$ARCHITECTURE"
# Win32
elif [ "`expr substr $(uname -s) 1 10`" == "MINGW32_NT" ]; then
NODE_BIN="node-win32-$ARCHITECTURE.exe"
NODE_BIN="node-$NODE_VERSION-win32-$ARCHITECTURE.exe"
# SunOS
elif [ "`uname`" == "SunOS" ]; then
NODE_BIN="node-sunos-$ARCHITECTURE.bin"
NODE_BIN="node-$NODE_VERSION-sunos-$ARCHITECTURE.bin"
else
unsupported_platform
@ -35,6 +37,8 @@ fi
NODE_PATH="./bin/node/$NODE_BIN"
echo $NODE_PATH
if [ ! -x $NODE_PATH ]; then
# As a last resource, try to use an already available node

View File

@ -3,7 +3,7 @@
:: http://stackoverflow.com/questions/12322308/batch-file-to-check-64bit-or-32bit-os
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set ARCH=x86 || set ARCH=x64
set NODE_PATH="%~dp0\node\node-win32-%ARCH%.exe"
set NODE_PATH="%~dp0\node\node-v0.12.0-win32-%ARCH%.exe"
@IF NOT EXIST %NODE_PATH% (
set NODE_PATH="node.exe"

View File

@ -7,7 +7,6 @@
"type": "git",
"url": "git@bitbucket.org:rulemotion/resin-cli.git"
},
"bundled_engine": "v0.12.0",
"preferGlobal": true,
"man": [
"./man/resin.1",
@ -17,9 +16,11 @@
"bin": {
"resin": "./bin/resin"
},
"bundled_engine": "v0.12.0",
"scripts": {
"prepublish": "gulp build",
"test": "gult test"
"test": "gult test",
"install": "node-binary download v0.12.0 ./bin/node --arch `node -e 'console.log(process.arch)'` --os `node -e 'console.log(process.platform)'`"
},
"keywords": [
"resin",
@ -56,6 +57,7 @@
"lodash": "~2.4.1",
"lodash-contrib": "~241.4.14",
"mkdirp": "~0.5.0",
"node-binary": "^1.0.0",
"nplugm": "^1.0.1",
"npm": "^2.5.1",
"open": "0.0.5",

View File

@ -61,7 +61,7 @@ function distribute() {
cp -vrf lib build/$package
cp -vrf package.json build/$package
download_node $os $arch $NODE_VERSION build/$package/bin/node
node ./node_modules/node-binary/bin/cli.js download $NODE_VERSION build/$package/bin/node --arch $arch --os $os
print_banner "Running npm install"