-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·48 lines (37 loc) · 1.01 KB
/
run.sh
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
#!/bin/bash
main() {
if [ "$WERCKER_NPM_CI_USE_CACHE" == "true" ]; then
info "Using wercker cache"
setup_cache
fi
set +e
npm_ci
set -e
success "Finished npm ci"
}
setup_cache() {
debug 'Creating $WERCKER_CACHE_DIR/wercker/npm'
mkdir -p "$WERCKER_CACHE_DIR/wercker/npm"
debug 'Configuring npm to use wercker cache'
npm config set cache "$WERCKER_CACHE_DIR/wercker/npm"
}
clear_cache() {
warn "Clearing npm cache"
npm cache clear
# make sure the cache contains something, so it will override cache that get's stored
debug 'Creating $WERCKER_CACHE_DIR/wercker/npm'
mkdir -p "$WERCKER_CACHE_DIR/wercker/npm"
printf keep > "$WERCKER_CACHE_DIR/wercker/npm/.keep"
}
npm_ci() {
local retries=2;
for try in $(seq "$retries"); do
info "Starting npm ci, try: $try"
npm ci $WERCKER_NPM_CI_OPTIONS && return;
if [ "$WERCKER_NPM_CI_CLEAR_CACHE_ON_FAILED" == "true" ]; then
clear_cache
fi
done
fail "Failed to successfully execute npm ci, retries: $retries"
}
main;