Created
July 8, 2016 13:57
-
-
Save tugberkugurlu/ea5c844236e29e45c1da0ce47a6a06e4 to your computer and use it in GitHub Desktop.
Patch project.json version, requires jq to be available on path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| for i in "$@" | |
| do | |
| case $i in | |
| -v=*|--version=*) | |
| VERSIONNUMBER="${i#*=}" | |
| shift # past argument=value | |
| ;; | |
| *) | |
| # unknown option | |
| ;; | |
| esac | |
| done | |
| echo "VERSION = ${VERSIONNUMBER}" | |
| if [ -z ${VERSIONNUMBER+x} ] | |
| then | |
| echo "No version is specified, defaulting to 0.0.0" | |
| VERSIONNUMBER=0.0.0 | |
| fi | |
| scriptsDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
| rootDir="$(dirname "$scriptsDir")" | |
| projectFiles=$rootDir/src/**/project.json | |
| for projectFile in $projectFiles | |
| do | |
| echo "patching $projectFile with version $VERSIONNUMBER" | |
| echo $(jq ". + { \"version\": \"$VERSIONNUMBER\" }" <<<$(jq 'del(.version)' <<<"$(cat $projectFile)")) > $projectFile | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment