How to push to github with custom commit message with npm scripts?

若如初见. 提交于 2019-12-07 05:23:31

问题


In my package.json I have this

  "scripts": {
    "start": "gulp serve",
    "git": "git add . && git commit -m 'some-message' && git push --all"
  },

In the terminal I run npm run git and the changes are pushed. But how can I change the commit message on the fly? For example npm run git MESSAGE='another commit'


回答1:


A solution involving some npm trickery might consist of:

"scripts": {
  "git": "git add . && git commit -m",
  "postgit": "git push --all"
},

To be called like:

npm run git -- "Message of the commit"

or:

npm run git -- Message


来源:https://stackoverflow.com/questions/44459774/how-to-push-to-github-with-custom-commit-message-with-npm-scripts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!