-
Notifications
You must be signed in to change notification settings - Fork 52
/
nodew
executable file
·26 lines (21 loc) · 968 Bytes
/
nodew
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
# https://github.com/srs/gradle-node-plugin/issues/24
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# This should match the "workDir" setting in build.gradle
NODEJS=$DIR/gradle/nodejs
NODE=node
NODE_VERSION_DEFAULT=0.12.7
#NODE=iojs
#NODE_VERSION_DEFAULT=1.7.1
# This probably won't work on Windows/Cygwin. Set NODE_HOME explicitly.
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
typeset -A arches=([x86_64]=x64 [x86]=x86) # not sure about the x86
arch=$(uname -m | tr '[:upper:]' '[:lower:]')
nodearch=${arches[$arch]}
# All of these may be overridden by the calling environment if needed.
NODE_VERSION=${NODE_VERSION:-${NODE_VERSION_DEFAULT}}
NODE_HOME="${NODE_HOME:-$NODEJS/${NODE}-v${NODE_VERSION}-${platform}-${nodearch}}"
NPM_HOME="${NPM_HOME:-${NODE_HOME}/lib/node_modules/npm}"
NODE_MODULES_HOME="${NODE_MODULES_HOME:-$DIR/node_modules}"
PATH="${NODE_MODULES_HOME}/.bin:${NPM_HOME}/bin:${NODE_HOME}/bin:${PATH}"
exec "${@}"