diff --git a/package.json b/package.json index 7779af5..5caea99 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,12 @@ "start": "node dist", "lint": "standard \"src/**/*.js\" \"test/**/*.js\"", "test-watch": "ava --watch", - "test": "ava --verbose" + "test": "ava --verbose", + "travis-encrypt": "./scripts/encrypt.sh" }, "husky": { "hooks": { - "pre-commit": "sh ./scripts/encrypt.sh", - "pre-push": "yarn lint && yarn test" + "pre-push": "./scripts/check-branch.sh && yarn lint && yarn test" } }, "repository": { diff --git a/scripts/check-branch.sh b/scripts/check-branch.sh new file mode 100755 index 0000000..5d0983b --- /dev/null +++ b/scripts/check-branch.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +ENCRYPT_MESSAGE="\nThe .env.enc file has not changed its contents from the version on origin/develop.\nTo ensure that tests pass in Travis, you need to encrypt the contents of .env before pushing to the remote, so that the Travis server can use your service account credentials.\nEnsure that the Travis CLI is installed on your local, run\n\n\tnpm run travis-encrypt\n\nand then push to the remote again.\nIf you don't care whether your build passes on Travis, you can run:\n\n\tgit push --no-verify\n\nand bypass this check.\n\n" + +# check whether .env.enc has changed +if [ -z "`git diff origin/develop -- .env.enc`" ]; then + echo $ENCRYPT_MESSAGE + exit 1 +fi + + diff --git a/scripts/encrypt.sh b/scripts/encrypt.sh index 4daa4c8..1609b0b 100644 --- a/scripts/encrypt.sh +++ b/scripts/encrypt.sh @@ -2,10 +2,10 @@ echo "Encrypting .env file for Travis..." # confirm that the user has the core repo as origin, and is therefore a maintainer -if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then - echo "Travis encryption not required for satellite contributors, continuing.." - exit 0 -fi +# if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then +# echo "Travis encryption not required for satellite contributors, continuing.." +# exit 0 +# fi # confirm travis is installed if [ ! hash travis 2>/dev/null ]; then