Skip to content

Commit

Permalink
chore: improve bash script robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyJones committed Jun 24, 2019
1 parent 24101e1 commit d74a61d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

npm run dist
${DIR}/prepare.sh
"${DIR}"/prepare.sh

# Link the build so that the examples are always testing the
# current build, in it's properly exported format
Expand All @@ -12,10 +12,11 @@ ${DIR}/prepare.sh

echo "Running e2e examples build for node version ${TRAVIS_NODE_VERSION}"
for i in examples/*; do
[ -e "$i" ] || continue # prevent failure if there are no examples
echo "------------------------------------------------"
echo "------------> continuing to test example project: $i"
cd "$i"
if [[ $i =~ "karma" ]]; then
if [[ "$i" =~ "karma" ]]; then
echo "linking pact-web"
npm link @pact-foundation/pact-web
else
Expand Down
4 changes: 3 additions & 1 deletion scripts/create_npmrc_file.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash -e

set +x #Don't echo the NPM key

NPMRC_FILE=.npmrc
echo "@pact-foundation:registry=https://registry.npmjs.org/" > $NPMRC_FILE
echo "@pact-foundation:registry=https://registry.npmjs.org/" > $NPMRC_FILE
echo "//registry.npmjs.org/:_authToken=${NPM_KEY}" >> $NPMRC_FILE
echo "//registry.npmjs.org/:username=pact-foundation" >> $NPMRC_FILE
echo "//registry.npmjs.org/:email=pact-foundation@googlegroups.com" >> $NPMRC_FILE
Expand Down
8 changes: 4 additions & 4 deletions scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ artifacts=(LICENSE *md package.json)

for artifact in "${artifacts[@]}"; do
echo " Copying ${artifact} => ./dist/${artifact}"
cp ${artifact} ./dist/${artifact}
cp "${artifact}" "./dist/${artifact}"
echo " Copying ${artifact} => ./dist-web/${artifact}"
cp ${artifact} ./dist-web/${artifact}
cp "${artifact}" "./dist-web/${artifact}"
done

echo "--> Creating pact-web package"
Expand All @@ -21,7 +21,7 @@ sed "s/VERSION/${VERSION}/g" < package.json.web > dist-web/package.json
types=( $(find dist -name "*.d.ts" | grep -v node_modules | sed 's/dist\///') )
for type in "${types[@]}"; do
echo " Copying ${type} => ./dist-web/${type}"
echo "creating dir: " $(dirname "./dist-web/${type}")
mkdir -p $(dirname "./dist-web/${type}")
echo "creating dir: $(dirname "./dist-web/${type}")"
mkdir -p "$(dirname "./dist-web/${type}")"
cp -r "dist/${type}" "./dist-web/${type}"
done
2 changes: 1 addition & 1 deletion scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

${DIR}/prepare.sh
"${DIR}"/prepare.sh

VERSION=$(grep '\"version\"' package.json | grep -E -o "([0-9\.]+(-[a-z\.0-9]+)?)")
echo "--> Releasing version ${VERSION}"
Expand Down

0 comments on commit d74a61d

Please sign in to comment.