Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
}
#!/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
You can’t perform that action at this time.