Skip to content

Commit b550ccc

Browse files
committed
feat-dev: Improv lint precommit msg & flow
1 parent cb31275 commit b550ccc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.husky/hook-utils.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
[ -z "$LOG_PREFIX" ] && LOG_PREFIX="[.husky/???]"
3+
4+
log() {
5+
echo "${LOG_PREFIX} $1"
6+
}
7+
8+
error() {
9+
echo >&2 "${LOG_PREFIX} $1"
10+
}

.husky/pre-commit

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run lint
4+
export NODE_ENV=production
5+
6+
LOG_PREFIX="[.husky/pre-commit]"
7+
8+
. "$(dirname "$0")/hook-utils.sh"
9+
10+
log "$> npm run lint"
11+
if ! npm run lint; then
12+
error "ERROR: Dirty code detected!"
13+
error "Fix the lint errors before committing to the repository."
14+
exit -1
15+
fi

0 commit comments

Comments
 (0)