This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnode-install.bash
executable file
·59 lines (48 loc) · 1.96 KB
/
node-install.bash
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
set -ueE -o pipefail
# Use the `DESIRED_NODE_VERSION` (defaults to the latest LTS node version) to install dependencies using `SETUP_COMMAND` (defaults to `npm install`).
# SCRIPT
#
# install:
# - eval "$(curl -fsSL https://raw.githubusercontent.com/bevry/awesome-travis/master/scripts/node-install.bash)"
# CUSTOM ENVIRONMENT VARIABLES
#
# DESIRED_NODE_VERSION
# To specify a specific node version (rather tha the LTS version):
# travis env set DESIRED_NODE_VERSION "7" --public
#
# SETUP_COMMAND
# To setup the project with a custom command, do so with:
# travis env set SETUP_COMMAND "npm run our:setup" --public
# Default User Environment Variables
if test -z "${DESIRED_NODE_VERSION-}"; then
DESIRED_NODE_VERSION="$(set +u && nvm version-remote --lts && set -u)"
else
DESIRED_NODE_VERSION="$(set +u && nvm version-remote "$DESIRED_NODE_VERSION" && set -u)"
fi
if test -z "${SETUP_COMMAND-}"; then
SETUP_COMMAND="npm run our:setup"
fi
# Set Local Environment Variables
CURRENT_NODE_VERSION="$(node --version)"
# Run
if test "$CURRENT_NODE_VERSION" = "$DESIRED_NODE_VERSION"; then
echo "running on node version $CURRENT_NODE_VERSION which IS the desired $DESIRED_NODE_VERSION"
echo "completing setup with $CURRENT_NODE_VERSION..."
eval "$SETUP_COMMAND"
echo "...setup complete with $CURRENT_NODE_VERSION"
else
echo "running on node version $CURRENT_NODE_VERSION which IS NOT the desired $DESIRED_NODE_VERSION"
echo "installing the desired version..."
set +u && nvm install "$DESIRED_NODE_VERSION" && set -u
echo "...installed the desired $DESIRED_NODE_VERSION"
echo "completing setup with $DESIRED_NODE_VERSION..."
eval "$SETUP_COMMAND"
echo "...setup complete with $DESIRED_NODE_VERSION"
echo "switching back to $CURRENT_NODE_VERSION"
set +u && nvm use "$CURRENT_NODE_VERSION" && set -u
echo "...switched back to $CURRENT_NODE_VERSION"
fi
# while our scripts pass linting, other scripts may not
# /home/travis/.travis/job_stages: line 81: secure: unbound
set +u