Running tsc build on git merge

For some reasons when running tsc –w (tsc in watch mode), will not detect file changes resulting from a git pull.

This caused multiple situation where we missed changes commited by the team in our local devs environments.

One very simple workaround to this is to simply create a git hook that would run the tsc compile for us on git merge. Git hook will get executed every time a git merge is completed.

In your repository, navigate the .git\hooks folder.

Now create an empty post-merge file (without extensions).

Add the following content

Start-Job -ScriptBlock { tsc }

If you are on linux, you may want something like this

Nohup tsc &

The start-job command ensure compilation will run in a background job without having your git client wait for tsc to complete.

Submit a Comment

Your email address will not be published. Required fields are marked *

Share This