Skip to content

Commit

Permalink
ci(package.json): use make
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai committed May 16, 2021
1 parent a6f8e0d commit 240bbf0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 6 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 240bbf0

Please sign in to comment.