Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / build-scripts / shrinkwrap
blob9b5eb05390b28029a02377ad65be906d40dcaaf2
1 #!/usr/bin/env bash
3 set -x
4 set -euo pipefail
5 IFS=$'\n\t'
7 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
8 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
10 pushd .
12 cd "${ROOT_DIR}"
14 rm -rf shared/node_modules modules/*/node_modules
15 mv node_modules/ node_modules_temp || true
17 function move_temp_modules_back {
18 # Move original node_modules back
19 if [[ -d node_modules_temp ]]; then
20 rm -rf node_modules/
21 mv node_modules_temp/ node_modules/ || true
24 trap move_temp_modules_back EXIT
26 # Remove the old shrinkwrap file
27 rm -f npm-shrinkwrap.json
29 npm cache clear
31 # Install production dependencies
32 npm i --production
34 # Perform shrinkwrap on production dependencies
35 npm shrinkwrap "$@"
37 # Now, override production node_modules
38 move_temp_modules_back
40 # Full install
41 npm prune
42 npm install
44 # Link Depenencies
45 linklocal link -r