Last active
June 22, 2016 02:13
-
-
Save jinahya/ccced0e4b6ec3a4605f083a019ee60c8 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
# by Jin Kwon <onacit_at_gmail.com> | |
# fetches all https://github.com/gruntjs/grunt-init-*.git repositories | |
# into to your ~/.grunt-init | |
# and (or) pull them all | |
# this script uses 'jq' command | |
gruntinit=~/.grunt-init | |
if [ ! -d $gruntinit ]; then | |
echo making directory $gruntinit | |
mkdir $gruntinit | |
fi | |
if which jq > /dev/null; then | |
# the command 'jq' is available | |
: | |
else | |
echo the command 'jq' not found! | |
exit 1; | |
fi | |
apiurl=https://api.github.com/search/repositories?q=grunt-init-%2Buser:gruntjs | |
curl -s $apiurl | jq -r '.items[].clone_url' | | |
{ | |
while read cloneurl | |
do | |
echo ---------------------------------------- | |
name=`echo $cloneurl | sed 's/.*\/\(grunt-init-.*\).git$/\1/'` | |
echo name: $name | |
path=$gruntinit/$name | |
if [ ! -d $path ]; then | |
echo cloning $cloneurl into $path | |
git clone -q $cloneurl $path | |
else | |
echo pulling $path | |
git -C $path pull -q | |
fi | |
done | |
} |
This file contains 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/sh | |
# by Jin Kwon <onacit_at_gmail.com> | |
# fetches all https://github.com/gruntjs/grunt-init-*.git repositories | |
# into to your ~/.grunt-init | |
# and (or) pull them all | |
# this script uses 'jq' command | |
# this script accept two options | |
# one is 'simple' which configs to clone with simple name without 'grunt-init-' prefixes. | |
# and the other is 'sample' which configs to include *-sample.git | |
simple=false | |
sample=false | |
for arg in "$@"; do | |
case "$arg" in | |
"simple") | |
simple=true | |
;; | |
"sample") | |
sample=true | |
;; | |
*) | |
;; | |
esac | |
done | |
#echo simple: $simple | |
#echo sample: $sample | |
gruntinit=~/.grunt-init | |
if [ ! -d $gruntinit ]; then | |
echo making directory $gruntinit | |
mkdir $gruntinit | |
fi | |
if which jq > /dev/null; then | |
# the command 'jq' is available | |
: | |
else | |
echo the command 'jq' not found! | |
exit 1; | |
fi | |
apiurl=https://api.github.com/search/repositories?q=grunt-init-%2Buser:gruntjs | |
curl -s $apiurl | jq -r '.items[].clone_url' | | |
{ | |
while read cloneurl | |
do | |
echo ---------------------------------------- | |
name=`echo $cloneurl | sed 's/.*\/\(grunt-init-.*\).git$/\1/'` | |
echo name: $name | |
if ! $sample; then | |
if [[ $name == *"-sample"* ]]; then | |
echo skipping a sample: $name | |
continue | |
fi | |
fi | |
if $simple ; then | |
name=`echo $cloneurl | sed 's/.*\/grunt-init-\(.*\).git$/\1/'` | |
echo using a simplified name: $name | |
fi | |
path=$gruntinit/$name | |
if [ ! -d $path ]; then | |
echo cloning $cloneurl into $path | |
git clone -q $cloneurl $path | |
else | |
echo pulling $path | |
git -C $path pull -q | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment