diff --git a/index.mk b/index.mk index f208779..26c0f1b 100644 --- a/index.mk +++ b/index.mk @@ -1,3 +1,4 @@ + # Export environment variables if a .env file is present. ifeq ($(ENV_EXPORTED),) # ENV vars not yet exported ifneq ("$(wildcard .env)","") @@ -21,6 +22,9 @@ export PATH := ./node_modules/.bin:$(PATH) # Use bash not sh SHELL := /bin/bash +# verify that secret-squirrel is set up to run on each commit +SQUIRRELIFY := $(shell node node_modules/@financial-times/n-gage/scripts/squirrelify.js) + # Some handy utilities GLOB = git ls-files -z $1 | tr '\0' '\n' | xargs -I {} find {} ! -type l NPM_INSTALL = npm prune --production=false --no-package-lock && npm install --no-package-lock @@ -34,6 +38,7 @@ CONFIG_VARS = curl -fsL https://ft-next-config-vars.herokuapp.com/$1/$(call APP_ IS_USER_FACING = `find . -type d \( -path ./bower_components -o -path ./node_modules \) -prune -o -name '*.html' -print` MAKEFILE_HAS_A11Y = `grep -rli "a11y" Makefile` + # # META TASKS # diff --git a/scripts/squirrelify.js b/scripts/squirrelify.js new file mode 100644 index 0000000..6474474 --- /dev/null +++ b/scripts/squirrelify.js @@ -0,0 +1,24 @@ +const packageJson = require(`${process.cwd()}/package.json`); + +const squirrelError = () => { + throw new Error(`secret-squirrel has not been configured to run on every commit +Add the following to your package.json + +"config": { + "pre-git": { + "pre-commit": [ + "node_modules/.bin/secret-squirrel" + ] + } +} +`); +} + +try { + const preCommit = packageJson.config['pre-git']['pre-commit']; + if (preCommit.indexOf('node_modules/.bin/secret-squirrel') === -1) { + squirrelError(); + } +} catch (e) { + squirrelError(); +}