diff --git a/.editorconfig b/.editorconfig index 9d5a4919..b53bd5df 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,3 +16,6 @@ trim_trailing_whitespace = false # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16a941f6..f0a68486 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,8 +59,8 @@ jobs: if: steps.yarn-cache.outputs.cache-hit != 'true' # Over here! run: yarn install --frozen-lockfile --ignore-scripts - - name: yarn test - run: yarn test + - name: make test + run: make test env: CI: true diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bb7e2570 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +SHELL = /bin/sh + +YARN = yarn +PRETTIER = $(YARN) prettier +ESLINT = $(YARN) eslint +JEST = $(YARN) test +TOUCH = touch + +ARTIFACTS = dist coverage +SRC_TS := $(wildcard ./src/*.ts) +ESLINT_GLOB = "{src,test}/**/*.ts" +PRETTIER_GLOB = "**/*.{js,ts,md,yml,json,html}" + +.DEFAULT_TARGET = all + +.PHONY: clean coverage build lint lint-fix production test + +all: production + +install: node_modules + +node_modules: yarn.lock + $(YARN) install + $(TOUCH) $@ + +production: install clean build + rm dist/tsconfig.tsbuildinfo + +clean: + rm -rf $(ARTIFACTS) + +build: dist + +dist: $(SRC_TS) + $(YARN) tsc + $(TOUCH) $@ + +lint: + $(ESLINT) $(ESLINT_GLOB) + $(PRETTIER) --list-different $(PRETTIER_GLOB) + +lint-fix: + $(ESLINT) --fix $(ESLINT_GLOB) + $(PRETTIER) --write $(PRETTIER_GLOB) + +test: clean build + $(JEST) + +coverage: clean build + $(JEST) --coverage --coverageReporters=lcov diff --git a/README.md b/README.md index e214f656..73a5230b 100644 --- a/README.md +++ b/README.md @@ -582,10 +582,10 @@ $ yarn lint:fix $ yarn build # unit tests -$ yarn test +$ yarn build && yarn test # code coverage -$ yarn cover +$ yarn build && yarn coverage ``` ## Changelog diff --git a/package.json b/package.json index 23a32797..919bf31d 100644 --- a/package.json +++ b/package.json @@ -8,20 +8,14 @@ "dist" ], "scripts": { - "clean": "rm -rf dist && rm -rf coverage", - "lint": "yarn prettier && yarn eslint", - "lint:fix": "yarn prettier:fix && yarn eslint:fix", - "eslint": "eslint '{src,test}/**/*.ts'", - "eslint:fix": "yarn eslint --fix", - "prettier": "prettier --list-different \"**/*.{js,ts,md,yml,json,html}\"", - "prettier:fix": "prettier --write \"**/*.{js,ts,md,yml,json,html}\"", - "prebuild": "yarn clean", + "clean": "make clean", + "lint": "make lint", + "lint:fix": "make lint-fix", "build": "tsc", - "pretest": "yarn build", "test": "jest", - "precoverage": "yarn build", - "coverage": "jest --coverage --coverageReporters=lcov", - "prepare": "husky install && yarn build && rm dist/tsconfig.tsbuildinfo" + "coverage": "make coverage", + "prepare": "husky install", + "prepack": "make production" }, "repository": { "type": "git",