I am creating a script to run through the entire 'build and push to git' flow. To commit my changes, I need to include the commit messages, but I want to have a unique message for every execution. Can I include a bash variable so that the user can create a message? I essentially want to do something like:
//package.json
{
...
"scripts": {
"build:push2Git $message": "npm run build:local ;
npm run build:webpack && git add . && git commit -m $message
&& git push origin my-branch || echo 'Failed to push to git'",
...
}
}
And then the script would be run as `npm run build:push2Git 'commit message #23445'. Is this possible? I realize my example may be horribly wrong, just my thought to explain what I want and how I would think it would work.
Just to give an update to what I tired, and passing it as a bash variable doesn't work.
So I tried :
//package.json
{
...
"scripts": {
"build:push2Git $message": "npm run build:local ;
npm run build:webpack && git add . && git commit -m '$1'
&& git push origin my-branch || echo 'Failed to push to git'",
...
}
}
and then try to call it as npm run build:push2Git my_custom_message
. Does not work. Pushed my code to my stash with the commit message "$1".