Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Feature/Add git pre-commit hook for yarn format (#2840)
Hugo Persson170b8acc65eb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex aa8361aace..817041403f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Added a hint for _Time-Weighted Rate of Return_ (TWR) to the portfolio summary tab on the home page- Added support for REST APIs (`JSON`) via the scraper configuration- Enabled the _Redis_ authentication in the `docker-compose` files+- Set up a git-hook to format the code before any commit### Changeddiff --git a/README.md b/README.mdindex d128f79483..dd580dfc96 100644--- a/README.md+++ b/README.md@@ -160,6 +160,7 @@ Ghostfolio is available for various home server systems, including [Runtipi](htt1. Run `yarn install`1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)1. Run `yarn database:setup` to initialize the database schema+1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks1. Start the server and the client (see [_Development_](#Development))1. Open http://localhost:4200/en in your browser1. Create a new user via _Get Started_ (this first user will get the role `ADMIN`)diff --git a/git-hooks/pre-commit b/git-hooks/pre-commitnew file mode 100755index 0000000000..673b3ba680--- /dev/null+++ b/git-hooks/pre-commit@@ -0,0 +1,26 @@+#!/bin/bash++# Will check if "yarn format" is run before executing.+# Called by "git commit" with no arguments. The hook should+# exit with non-zero status after issuing an appropriate message if+# it wants to stop the commit.++echo "Running yarn format"++# Run the command and loop over its output+FILES_TO_STAGE=""+i=0+while IFS= read -r line; do+ # Process each line here+ ((i++))+ if [ $i -le 2 ]; then+ continue+ fi+ if [[ $line == Done* ]]; then+ break+ fi+ FILES_TO_STAGE="$FILES_TO_STAGE $line"++done < <(yarn format )+git add $FILES_TO_STAGE+echo "Files formatted. Committing..."