Skip to content

Commit 61336a7

Browse files
authored
Merge pull request #433 from nschonni/shellcheck
Add Shellcheck to Travis and fix existing checks
2 parents df1d938 + c11be06 commit 61336a7

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ sudo: required
33
services:
44
- docker
55

6+
addons:
7+
apt:
8+
sources:
9+
- debian-sid
10+
packages:
11+
- shellcheck
12+
613
script:
14+
- shellcheck *.sh
715
- ./test-build.sh $NODE_VERSION
816

917
env:

generate-stackbrew-library.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ set -e
33

44
hash git 2>/dev/null || { echo >&2 "git not found, exiting."; }
55

6+
# Used dynamically: print "$array_" $1
7+
# shellcheck disable=SC2034
68
array_4_8='4 argon';
9+
# shellcheck disable=SC2034
710
array_6_11='6 boron';
11+
# shellcheck disable=SC2034
812
array_8_1='8 latest';
913

10-
cd $(cd ${0%/*} && pwd -P);
14+
cd "$(cd "${0%/*}" && pwd -P)";
1115

12-
self="$(basename "$BASH_SOURCE")"
16+
self="$(basename "${BASH_SOURCE[0]}")"
1317

1418
versions=( */ )
1519
versions=( "${versions[@]%/}" )
@@ -40,7 +44,7 @@ for version in "${versions[@]}"; do
4044
# Skip "docs" and other non-docker directories
4145
[ -f "$version/Dockerfile" ] || continue
4246

43-
eval stub=$(echo "$version" | awk -F. '{ print "$array_" $1 "_" $2 }');
47+
eval stub="$(echo "$version" | awk -F. '{ print "$array_" $1 "_" $2 }')";
4448
commit="$(fileCommit "$version")"
4549
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
4650

@@ -51,7 +55,7 @@ for version in "${versions[@]}"; do
5155
echo "Directory: ${version}"
5256
echo
5357

54-
variants=$(echo $version/*/ | xargs -n1 basename)
58+
variants=$(echo "$version"/*/ | xargs -n1 basename)
5559
for variant in $variants; do
5660
# Skip non-docker directories
5761
[ -f "$version/$variant/Dockerfile" ] || continue

test-build.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fatal() {
1616
exit 1
1717
}
1818

19-
cd $(cd ${0%/*} && pwd -P);
19+
cd "$(cd "${0%/*}" && pwd -P)" || exit;
2020

2121
versions=( "$@" )
2222
if [ ${#versions[@]} -eq 0 ]; then
@@ -28,40 +28,38 @@ for version in "${versions[@]}"; do
2828
# Skip "docs" and other non-docker directories
2929
[ -f "$version/Dockerfile" ] || continue
3030

31-
tag=$(cat $version/Dockerfile | grep "ENV NODE_VERSION" | cut -d' ' -f3)
31+
tag=$(grep "ENV NODE_VERSION" "$version/Dockerfile" | cut -d' ' -f3)
3232

3333
info "Building $tag..."
34-
docker build -t node:$tag $version
3534

36-
if [[ $? -gt 0 ]]; then
35+
if ! docker build -t node:"$tag" "$version"; then
3736
fatal "Build of $tag failed!"
3837
else
3938
info "Build of $tag succeeded."
4039
fi
4140

42-
OUTPUT=$(docker run --rm -it node:$tag node -e "process.stdout.write(process.versions.node)")
41+
OUTPUT=$(docker run --rm -it node:"$tag" node -e "process.stdout.write(process.versions.node)")
4342
if [ "$OUTPUT" != "$tag" ]; then
4443
fatal "Test of $tag failed!"
4544
else
4645
info "Test of $tag succeeded."
4746
fi
4847

49-
variants=$(echo $version/*/ | xargs -n1 basename)
48+
variants=$(echo "$version"/*/ | xargs -n1 basename)
5049

5150
for variant in $variants; do
5251
# Skip non-docker directories
5352
[ -f "$version/$variant/Dockerfile" ] || continue
54-
53+
5554
info "Building $tag-$variant variant..."
56-
docker build -t node:$tag-$variant $version/$variant
5755

58-
if [[ $? -gt 0 ]]; then
56+
if ! docker build -t node:"$tag-$variant" "$version/$variant"; then
5957
fatal "Build of $tag-$variant failed!"
6058
else
6159
info "Build of $tag-$variant succeeded."
6260
fi
6361

64-
OUTPUT=$(docker run --rm -it node:$tag-$variant node -e "process.stdout.write(process.versions.node)")
62+
OUTPUT=$(docker run --rm -it node:"$tag-$variant" node -e "process.stdout.write(process.versions.node)")
6563
if [ "$OUTPUT" != "$tag" ]; then
6664
fatal "Test of $tag-$variant failed!"
6765
else

update.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -e
33

4-
cd $(cd ${0%/*} && pwd -P);
4+
cd "$(cd "${0%/*}" && pwd -P)";
55

66
versions=( "$@" )
77
if [ ${#versions[@]} -eq 0 ]; then
@@ -39,7 +39,7 @@ for version in "${versions[@]}"; do
3939

4040
update_node_version
4141

42-
variants=$(echo $version/*/ | xargs -n1 basename)
42+
variants=$(echo "$version"/*/ | xargs -n1 basename)
4343

4444
for variant in $variants; do
4545
# Skip non-docker directories

0 commit comments

Comments
 (0)