[英]Update/bump npm package version before Git commit
I have an Ember NPM based project & use Git for versioning.我有一个基于 Ember NPM 的项目并使用 Git 进行版本控制。
I want to update/bump the package.json version before/while doing Git commit.我想在执行 Git 提交之前/同时更新/修改 package.json 版本。
How do I achieve this?我如何实现这一目标? Do I need to use some kind of Git hooks?
我需要使用某种 Git 钩子吗?
Try a pre-commit hook.尝试预提交钩子。 Found an article on medium which can help you build a pre-commit hook.
在 medium 上找到了一篇文章,可以帮助您构建预提交挂钩。
https://medium.com/the-andela-way/git-hooks-beautifully-automate-tasks-stages-bfb29f42fea1 https://medium.com/the-andela-way/git-hooks-beautifully-automate-tasks-stages-bfb29f42fea1
Made a git-hook.做了一个 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参考: 按更改类型过滤 git diff
ref: https://stackoverflow.com/a/3068990/1608320参考: https : //stackoverflow.com/a/3068990/1608320
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.