Skip to content

Commit 59002e1

Browse files
devversionandrewseguin
authored andcommitted
build: setup ng-dev format pre-commit hook
Whenever a commit is being created, the `yarn ng-dev format changed` command is being executed. This means that the formatter does not need to be run manually.
1 parent 3704400 commit 59002e1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.husky/pre-commit

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
# Allow for the formatting command to fail without exiting the script.
5+
set +e
6+
7+
yarn -s ng-dev format staged 2>/dev/null
8+
9+
if [ $? -ne 0 ]; then
10+
echo "WARNING: failed to run file formatting (ng-dev format staged)"
11+
fi

DEV_ENVIRONMENT.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,18 @@ packages locally and test them by either of the following ways:
6464
If you're making changes to a public API, they need to be propagated to our public API golden files.
6565
To save the changes you can run `yarn approve-api <target>` and to review the changes, you can look
6666
at the file under `tools/public_api_guard/<target>.d.ts`.
67+
68+
69+
### Disabling Git hooks
70+
71+
If your development workflow does not intend the commit message validation to run automatically
72+
when commits are being created, or if you do not want to run the formatter upon `git commit`, you
73+
can disable any installed Git hooks by setting `HUSKY=0` in your shell environment. e.g.
74+
75+
```bash
76+
# .zshrc
77+
export HUSKY=0
78+
79+
# .bashrc
80+
export HUSKY=0
81+
```

0 commit comments

Comments
 (0)