Permalink
Browse files

Abstract out build() method

  • Loading branch information...
1 parent 109f7aa commit 6c9e612da5a48a785bbfff58087b388d16ba6a80 @welwood08 welwood08 committed with Dec 2, 2011
Showing with 16 additions and 13 deletions.
  1. +16 −13 nave.sh
View
29 nave.sh
@@ -127,19 +127,22 @@ nave_fetch () {
remove_dir "$src"
ensure_dir "$src"
- # fixme: use array here.
- local url="http://nodejs.org/dist/v$version/node-v$version.tar.gz"
- local url2="http://nodejs.org/dist/node-v$version.tar.gz"
- local url3="http://nodejs.org/dist/node-$version.tar.gz"
- curl -# -L "$url" \
- | $tar xzf - -C "$src" --strip-components=1 \
- || curl -# -L "$url2" \
- | $tar xzf - -C "$src" --strip-components=1 \
- || curl -# -L "$url3" \
- | $tar xzf - -C "$src" --strip-components=1 \
- || fail "Couldn't fetch $version"
+ local url
+ local urls=(
+ "http://nodejs.org/dist/v$version/node-v$version.tar.gz"
+ "http://nodejs.org/dist/node-v$version.tar.gz"
+ "http://nodejs.org/dist/node-$version.tar.gz"
+ )
+ for url in "${urls[@]}"; do
+ curl -#Lf "$url" \
+ | $tar xzf - -C "$src" --strip-components=1
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
+ done
- return 0
+ remove_dir "$src"
+ fail "Couldn't fetch $version"
}
build () {
@@ -176,7 +179,7 @@ nave_usemain () {
return 0
fi
- build "$version in main env" "$prefix"
+ build "$version" "$prefix"
}
nave_install () {

0 comments on commit 6c9e612

Please sign in to comment.