I'm new to writting bash script and I have a npm package that I created https://www.npmjs.com/package/comgen
Bash
days=3
hours=24
minutes=60
totalNumberOfCommits=3
lenghtOfTime=$((days*hours*minutes))
arrayOfCommits=$(shuf -i 1-$lenghtOfTime -n $totalNumberOfCommits | sort -r -n)
for index in $arrayOfCommits
do
randomMessage=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
git commit --allow-empty --date "$(date -d "-$index minutes")" -m "$randomMessage"
done
git push origin master
You run it like this npm run comgen I want it to run like this:
npm run comgen -days "x number of days" -totalNumberOfCommits "x number of commits"
Package.json
"scripts": {
"comgen": "commit-generator.sh"
},
Where the number of days and the total of commits passed will replace the number in the variables I have in the bash script.
I read this SO questions before postins my own: https://unix.stackexchange.com/questions/32290/pass-command-line-arguments-to-bash-script