Last active
January 21, 2017 14:18
-
-
Save gko/159085ce9c09ac9e81b5a06e87a5eef2 to your computer and use it in GitHub Desktop.
create npm project both locally and on github
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
#!/usr/bash | |
# Create npm package and repo for it on github | |
# usage: project test | |
# for private repo: project -p test | |
project() { | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-p|--private) | |
local private=1 | |
;; | |
*) | |
local name="$1" | |
;; | |
esac | |
shift | |
done | |
if [ -z "$name" ]; then | |
return 1 | |
fi | |
mkdir -p ~/projects/"$name" | |
cd ~/projects/"$name" | |
if [ -d ./.git ]; then | |
return 0 | |
fi | |
hub init . | |
if npm -v 2>/dev/null; then | |
npm init | |
fi | |
if [[ $private -eq 1 ]]; then | |
hub create -p $name | |
else | |
hub create $name | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment