@@ -33,13 +33,13 @@ COMMITLINT ?= $(BIN_DIR)/commitlint
3333COMMITLINT_FLAGS ?= \
3434 --cwd "$(ROOT_DIR ) " \
3535 --config "$(CONFIG_DIR ) /commitlint/.commitlintrc.js" \
36- --edit
36+ --verbose
3737
3838
3939# RULES #
4040
4141# /
42- # Lints a commit message .
42+ # Lints a commit.
4343#
4444# ## Notes
4545#
@@ -52,7 +52,60 @@ COMMITLINT_FLAGS ?= \
5252# /
5353commitlint : $(NODE_MODULES )
5454 $(QUIET ) mv $(ROOT_DIR ) /tsconfig.json $(ROOT_DIR ) /tsconfig.json.tmp
55- $(QUIET ) NODE_PATH=" $( NODE_PATH) " $(NODE ) " $( COMMITLINT) " $(COMMITLINT_FLAGS ) || (mv $( ROOT_DIR) /tsconfig.json.tmp $( ROOT_DIR) /tsconfig.json && exit 1)
55+ $(QUIET ) NODE_PATH=" $( NODE_PATH) " $(NODE ) " $( COMMITLINT) " $(COMMITLINT_FLAGS ) --edit || ( mv $( ROOT_DIR) /tsconfig.json.tmp $( ROOT_DIR) /tsconfig.json && exit 1 )
5656 $(QUIET ) mv $(ROOT_DIR ) /tsconfig.json.tmp $(ROOT_DIR ) /tsconfig.json
5757
5858.PHONY : commitlint
59+
60+ # /
61+ # Lints a commit message.
62+ #
63+ # ## Notes
64+ #
65+ # - We have to temporarily move the `tsconfig` file, as `commitlint` (erroneously) attempts to use the file for compiling TypeScript.
66+ #
67+ # @private
68+ #
69+ # @example
70+ # make commitlint-message
71+ # /
72+ commitlint-message : $(NODE_MODULES )
73+ $(QUIET ) mv $(ROOT_DIR ) /tsconfig.json $(ROOT_DIR ) /tsconfig.json.tmp
74+ $(QUIET ) ( printf " $( GIT_COMMIT_MESSAGE) " | NODE_PATH=" $( NODE_PATH) " $( NODE) " $( COMMITLINT) " $( COMMITLINT_FLAGS) ) || ( mv $( ROOT_DIR) /tsconfig.json.tmp $( ROOT_DIR) /tsconfig.json && exit 1 )
75+ $(QUIET ) mv $(ROOT_DIR ) /tsconfig.json.tmp $(ROOT_DIR ) /tsconfig.json
76+
77+ .PHONY : commitlint-message
78+
79+ # /
80+ # Lints a list of files, each containing a commit message.
81+ #
82+ # ## Notes
83+ #
84+ # - We have to temporarily move the `tsconfig` file, as `commitlint` (erroneously) attempts to use the file for compiling TypeScript.
85+ #
86+ # @private
87+ #
88+ # @param {string} FILES - list of file paths
89+ # @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
90+ #
91+ # @example
92+ # make commitlint-files FILES='/foo/commit.txt'
93+ # /
94+ commitlint-files : $(NODE_MODULES )
95+ $(QUIET ) mv $(ROOT_DIR ) /tsconfig.json $(ROOT_DIR ) /tsconfig.json.tmp
96+ ifeq ($(FAIL_FAST ) , true)
97+ $(QUIET) for file in $(FILES); do \
98+ echo ''; \
99+ echo "Linting commit message:"; \
100+ ( cat $$file | grep -v '^# ' | $(NODE) "$(COMMITLINT)" $(COMMITLINT_FLAGS) ) || ( mv $(ROOT_DIR)/tsconfig.json.tmp $(ROOT_DIR)/tsconfig.json && exit 1 ); \
101+ done
102+ else
103+ $(QUIET) for file in $(FILES); do \
104+ echo ''; \
105+ echo "Linting commit message"; \
106+ ( cat $$file | grep -v '^# ' | $(NODE) "$(COMMITLINT)" $(COMMITLINT_FLAGS) ) || echo 'Linting failed.'; \
107+ done
108+ endif
109+ $(QUIET) mv $(ROOT_DIR)/tsconfig.json.tmp $(ROOT_DIR)/tsconfig.json
110+
111+ .PHONY : commitlint-files
0 commit comments