When I get to work each morning I run a script that pulls multiple repositories my company uses:
#!/bin/bash
cd ~/myCompany/rep1
git pull --rebase
git submodule update
cd ~/myCompany/rep2
git pull --rebase
npm install
npm run build
cd ~/myCompany/rep3
git pull --rebase
npm install
npm run build
cd ~/myCompany/rep4
git pull --rebase
npm install
npm run build
cd ~/myCompany/rep5
git pull --rebase
git submodule update
echo "done!"
As you can see, different repositories need to be built while others need a submodule update
and so on.
I was wondering if theres any way to make this script run each git pull and their respective commands in parallel instead of one after the other. Does anyone know how I'd achieve such a thing?
Make it a function, call the function in the background:
#!/bin/bash
npmBuild() {
cd $1
git pull --rebase
npm install
npm run build
}
npmBuild ~/myCompany/rep2 &
npmBuild ~/myCompany/rep3 &
Make a slightly different function for the ones where you don't npm
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With