install-node: hardcode the path for npm.

This replaces nvm in npm-wrapper by harcoding the path the way we do
with node.  The main benefit is that this saves a few hundred
milliseconds every time we invoke npm.
This commit is contained in:
sinwar 2017-06-10 11:46:47 +05:30 committed by Tim Abbott
parent 774216713b
commit 9cab965601
2 changed files with 3 additions and 3 deletions

View File

@ -11,6 +11,7 @@ source "$NVM_DIR/nvm.sh"
node_version=6.6.0 node_version=6.6.0
nvm install "$node_version" && nvm alias default "$node_version" nvm install "$node_version" && nvm alias default "$node_version"
export NODE_BIN="$(nvm which default)" export NODE_BIN="$(nvm which default)"
export NPM_BIN=$(echo "$NODE_BIN" | sed 's/node$/npm/')
# Fix messed-up uid=500 and group write bits produced by nvm # Fix messed-up uid=500 and group write bits produced by nvm
n=$(which node) n=$(which node)
@ -22,3 +23,4 @@ chmod -R go-w "$n"
cp "$ZULIP_PATH/../../scripts/setup/node-wrapper" /usr/local/bin/node cp "$ZULIP_PATH/../../scripts/setup/node-wrapper" /usr/local/bin/node
sed -i "s|NODE_PATH|$NODE_BIN|" /usr/local/bin/node sed -i "s|NODE_PATH|$NODE_BIN|" /usr/local/bin/node
cp "$ZULIP_PATH/../../scripts/setup/npm-wrapper" /usr/local/bin/npm cp "$ZULIP_PATH/../../scripts/setup/npm-wrapper" /usr/local/bin/npm
sed -i "s|NPM_PATH|$NPM_BIN|" /usr/local/bin/npm

View File

@ -1,4 +1,2 @@
#!/bin/bash #!/bin/bash
export NVM_DIR="/usr/local/nvm" NPM_PATH "$@"
[ -e "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
npm "$@"