-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
49 lines (37 loc) · 1.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
.DELETE_ON_ERROR:
BIN_DIR := ./bin
BUILD_DIR := ./build
SRC_DIR := ./src
SCHEMA_DIR := $(SRC_DIR)/schema
export PATH := $(BIN_DIR):./node_modules/.bin/:$(PATH)
SRC_SCHEMA := $(shell ls $(SCHEMA_DIR)/*.js)
BUILD_SCHEMA := $(patsubst $(SCHEMA_DIR)/%.js,$(BUILD_DIR)/%.json,$(SRC_SCHEMA))
ALL_JS := $(shell find $(SRC_DIR) -type f -name '*.js') $(shell ls $(BIN_DIR)/*)
.PHONY: build
build: $(BUILD_SCHEMA) $(BUILD_DIR)/package.json $(BUILD_DIR)/readme.md
# Install dependencies
node_modules/.install: package.json
@npm install
@touch $@
# Build all schema
$(BUILD_SCHEMA): $(SRC_SCHEMA) node_modules/.install
@mkdir -p $(dir $@)
@format.js $(patsubst $(BUILD_DIR)/%.json,$(SCHEMA_DIR)/%.js,./$@) > $@
$(BUILD_DIR)/package.json: package.json node_modules/.install
@mkdir -p $(dir $@)
@transform-package-json.js package.json > $@
$(BUILD_DIR)/readme.md: readme.md
@mkdir -p $(dir $@)
@cp readme.md $@
.PHONY: test
test: build lint
@node test/test.js
.PHONY: lint
lint: $(ALL_JS) node_modules/.install
@eslint $(ALL_JS);
.PHONY: lint-fix
lint-fix: $(ALL_JS) node_modules/.install
@eslint --fix $(ALL_JS);
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR)