From a548e8a9afc1afacaaf3368bcf30cbb025b5c5f0 Mon Sep 17 00:00:00 2001 From: mohit Date: Wed, 15 Nov 2017 23:30:36 +0000 Subject: [PATCH] add typecheck for node.mk --- make/README.md | 5 ++++- make/node.mk | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/make/README.md b/make/README.md index 82d60e96..669ace27 100644 --- a/make/README.md +++ b/make/README.md @@ -50,8 +50,11 @@ $(eval $(call node-version-check,$(NODE_VERSION))) check-coffee-file-count: $(call node-coffeescript-file-count-check,$(COFFEE_FILE_COUNT)) +typechecker: + $(call node-typecheck,backend/server.ts) + run: - NODE_ENV=development node_modules/node-dev/bin/node-dev server.coffee + NODE_ENV=development node_modules/.bin/ts-node --ignoreWarnings 2307 backend/server.ts ``` ## Thrift diff --git a/make/node.mk b/make/node.mk index 6b0649e1..ad799c2e 100644 --- a/make/node.mk +++ b/make/node.mk @@ -59,6 +59,17 @@ else \ fi endef +# node-typecheck is a target for calling the typescript type checker on a repo. +# It takes a single argument which is the entrypoint for the app. +define node-typecheck +./node_modules/.bin/ts-node --ignoreWarnings 2307 -e 'import "$(1)"; process.exit(0)' > /tmp/node-mk-typecheck 2>&1 || true +-@grep "compile TypeScript" /tmp/node-mk-typecheck | wc -l > /tmp/node-mk-typecheck-fail-count +@if [ "`cat /tmp/node-mk-typecheck-fail-count`" -gt "0" ]; then \ + cat /tmp/node-mk-typecheck; \ + exit 1; \ +fi +endef + # node-coffee-edit-check exits non-zero if this branch adds any lines to # coffeescript files. NOTE: Uses the merge-base, as otherwise we would get # changes in master that were merged after this branch diverged from master.