-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathnpm-install-dependencies.sh
More file actions
executable file
·51 lines (44 loc) · 1.4 KB
/
npm-install-dependencies.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.4 KB
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
#!/bin/bash
source ./helpers.sh
environment=$1
npm_install_command=$2
cd /usr/src/app/app/
mkdir -p /usr/src/app/app/node_modules/
# Copy service dependencies if any
if [ $environment == "development" ] && [ -d /app/node_modules/ ]
then
docker-rsync /app/node_modules /usr/src/app/app/
fi
# Install service dependencies
if [ "$npm_install_command" == "ci" ]
then
echo "Installing dependencies from package-lock.json"
npm ci
if [ "$?" != "0" ]
then
echo "npm ci failed. Remove package-lock.json and restart."
exit 1 # may not exit the full template
fi
elif [ "$npm_install_command" == "install" ]
then
echo "Installing dependencies from package.json"
npm install
if [ "$?" != "0" ]
then
echo "npm install failed."
exit 1 # may not exit the full template
fi
fi
# Copy template dependencies
docker-rsync /usr/src/app/node_modules /usr/src/app/app
cp -R /usr/src/app/helpers/mu /usr/src/app/app/node_modules/mu
# Copy merged dependencies back to the mounted service folder
if [ $environment == "development" ] && [ "$npm_install_command" != "" ]
then
docker-rsync --delete /usr/src/app/app/node_modules/ /app/node_modules
fi
# Copy package-lock.json of service dependencies back to mounted service folder
if [ $environment == "development" ] && [ "$npm_install_command" == "install" ] && [ -f /usr/src/app/app/package-lock.json ]
then
docker-rsync /usr/src/app/app/package-lock.json /app/
fi