"scripts": {
"cr": "git commit -am ${message} && git pull origin master --rebase && git push --force",
}
I'm trying to figure out how to run the above with something like:
# yarn cr "commit message"
"scripts": {
"cr": "git commit -am ${message} && git pull origin master --rebase && git push --force",
}
I'm trying to figure out how to run the above with something like:
# yarn cr "commit message"
Yes. you can do something like this
"scripts": {
{
"cr": "f(){ git commit -am $1;};f",
}
}
and yarn run cr -- 'commit message'
you can pass n number of arguments seperated with space and can be accesible via $1 ,$2 ..
The pattern sh -c 'shell_command'
works on *nix and Windows Powershell. Then, you can use $0
, $1
, and so on to access the command line arguments. So write this in your package.json
:
"scripts": {
"cr": "sh -c 'git commit -am $0 && git pull origin master --rebase && git push --force'",
}
Now you can run this command in a terminal:
yarn cr commit_message