-
Notifications
You must be signed in to change notification settings - Fork 58
/
check-releases.sh
executable file
·43 lines (33 loc) · 1.12 KB
/
check-releases.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
#!/bin/bash
# Given a disttype (release, rc, nightly, test), check for new releases on
# nodejs.org and print them to stdout.
# The first run of this file won't print anything but will save current state
# to ../../var/ so subsequent runs will pick up the difference.
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
vardir="$(realpath "${__dirname}/../../var/")"
disttype="$1"
if [ "X$disttype" = "X" ]; then
echo "Usage: check-releases.sh <disttype>"
exit 1
fi
last_file="${vardir}/check-releases-${disttype}-latest-index.tab"
new_file="${vardir}/check-releases-${disttype}-new-index.tab"
index_tab_url="https://nodejs.org/download/${disttype}/index.tab"
function fetch_latest {
curl -sL $index_tab_url | awk '{ print $1 }'
}
# first check
if ! test -e $last_file ; then
fetch_latest > $last_file
exit 0
fi
fetch_latest > $new_file
# no changes, or maybe there's weirdness
if [ $(wc -l $new_file | cut -d' ' -f1) -le $(wc -l $last_file | cut -d' ' -f1) ] ; then
rm $new_file
exit 0
fi
for new in $(diff $last_file $new_file | grep '>' | awk '{ print $2 }'); do
echo $new
done
mv $new_file $last_file