Skip to content

Commit 8c38b2f

Browse files
author
Christopher Horrell
committed
update Node.js and npm separately
update.sh now just updates Node.js, update-npm.sh updates npm
1 parent 6b7c13c commit 8c38b2f

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

update-npm.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -e
3+
4+
hash npm 2>/dev/null || { echo >&2 "npm not found, exiting."; }
5+
6+
cd $(cd ${0%/*} && pwd -P);
7+
8+
versions=( "$@" )
9+
if [ ${#versions[@]} -eq 0 ]; then
10+
versions=( */ )
11+
fi
12+
versions=( "${versions[@]%/}" )
13+
14+
npmVersion="$(npm show npm version 2>/dev/null)"
15+
for version in "${versions[@]}"; do
16+
fullVersion="$(curl -sSL --compressed 'http://nodejs.org/dist' | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -f 3 -d . | sort -n | tail -1)"
17+
(
18+
sed -E -i.bak '
19+
s/^(ENV NPM_VERSION) .*/\1 '"$npmVersion"'/;
20+
' "$version/Dockerfile" "$version/slim/Dockerfile" "$version/wheezy/Dockerfile"
21+
rm $version/Dockerfile.bak $version/slim/Dockerfile.bak $version/wheezy/Dockerfile.bak
22+
)
23+
done

update.sh

-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ if [ ${#versions[@]} -eq 0 ]; then
1111
fi
1212
versions=( "${versions[@]%/}" )
1313

14-
npmVersion="$(npm show npm version 2>/dev/null)"
1514
for version in "${versions[@]}"; do
1615
fullVersion="$(curl -sSL --compressed 'http://nodejs.org/dist' | grep '<a href="v'"$version." | sed -E 's!.*<a href="v([^"/]+)/?".*!\1!' | cut -f 3 -d . | sort -n | tail -1)"
1716
(
1817
sed -E -i.bak '
1918
s/^(ENV NODE_VERSION) .*/\1 '"$version.$fullVersion"'/;
20-
s/^(ENV NPM_VERSION) .*/\1 '"$npmVersion"'/;
2119
' "$version/Dockerfile" "$version/slim/Dockerfile" "$version/wheezy/Dockerfile"
2220
rm $version/Dockerfile.bak $version/slim/Dockerfile.bak $version/wheezy/Dockerfile.bak
2321

0 commit comments

Comments
 (0)