Skip to content

Commit

Permalink
build: setup ng-dev format pre-commit hook
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devversion authored and andrewseguin committed Oct 18, 2021
1 parent 3704400 commit 59002e1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Allow for the formatting command to fail without exiting the script.
set +e

yarn -s ng-dev format staged 2>/dev/null

if [ $? -ne 0 ]; then
echo "WARNING: failed to run file formatting (ng-dev format staged)"
fi
15 changes: 15 additions & 0 deletions DEV_ENVIRONMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,18 @@ packages locally and test them by either of the following ways:
If you're making changes to a public API, they need to be propagated to our public API golden files.
To save the changes you can run `yarn approve-api <target>` and to review the changes, you can look
at the file under `tools/public_api_guard/<target>.d.ts`.


### Disabling Git hooks

If your development workflow does not intend the commit message validation to run automatically
when commits are being created, or if you do not want to run the formatter upon `git commit`, you
can disable any installed Git hooks by setting `HUSKY=0` in your shell environment. e.g.

```bash
# .zshrc
export HUSKY=0

# .bashrc
export HUSKY=0
```

0 comments on commit 59002e1

Please sign in to comment.