0

I have an Ember NPM based project & use Git for versioning.

I want to update/bump the package.json version before/while doing Git commit.

How do I achieve this? Do I need to use some kind of Git hooks?

halfer
  • 19,824
  • 17
  • 99
  • 186
copenndthagen
  • 49,230
  • 102
  • 290
  • 442

1 Answers1

0

Try a pre-commit hook. Found an article on medium which can help you build a pre-commit hook.

https://medium.com/the-andela-way/git-hooks-beautifully-automate-tasks-stages-bfb29f42fea1

Made a git-hook. let me know if this is what you were looking for. There are some in-line comments too which you can use for adding more changed files.

pre-commit

#!/bin/sh
echo "START pre-commit hook"
npm update --save

echo "removing older changed files"

#rm changed.js

#echo "adding package.json and package-lock for changes happened inside npm update"
git add package.json package-lock.json

#echo "adding the changed files only"
#git diff --cached --name-only --diff-filter=ACM > changed.js

#echo "running git add aganist changed.js files"
#git add ./changed.js

echo "END"

ref: Filter git diff by type of change

ref: https://stackoverflow.com/a/3068990/1608320

dixitk13
  • 523
  • 4
  • 10