-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnpm.sh
executable file
·47 lines (31 loc) · 1.01 KB
/
npm.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
#!/usr/bin/env bash
### RUN /bin/bash -c "source /usr/local/bin/virtualenvwrapper.sh"
if [[ "$npm_registry_override" != "yes" ]]; then
echo "refusing to source npm.sh script because env is not set."
return 0;
fi
npm(){
# make request to local server
# local server responds with multiple files
# for each file save them in the npm cache
# the add the args below
echo "running the npm override..";
echo "running the npm patch" >&2;
(
set -e;
rm -rf "$HOME/.npm-temp-cache";
mkdir -p "$HOME/.npm-temp-cache";
cd "$HOME/.npm-temp-cache"
# nc localhost 3440 | tar -x > ores.tgz
nc "npm_registry_server" 3440 | tar -x -O > ores-$(date +%s.%N).tgz
for x in *; do
echo "npm is adding this tar file to the cache: $x";
command npm cache add "$x";
done
)
local exit_code="$?"
if [[ "$exit_code" != "0" ]]; then
echo "warning, we might not have been able to get new cache.";
fi
command npm "$@" --cache-min=99999 --prefer-offline
}