Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from Financial-Times/rhys/setup-squirrel
Browse files Browse the repository at this point in the history
verify squirrle configured properly
  • Loading branch information
wheresrhys authored Jun 19, 2017
2 parents f27e0b0 + f1d4904 commit 1f0becb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Export environment variables if a .env file is present.
ifeq ($(ENV_EXPORTED),) # ENV vars not yet exported
ifneq ("$(wildcard .env)","")
Expand All @@ -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
Expand All @@ -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
#
Expand Down
24 changes: 24 additions & 0 deletions scripts/squirrelify.js
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 1f0becb

Please sign in to comment.