Skip to content

Instantly share code, notes, and snippets.



Last active Dec 11, 2015
What would you like to do?
Bash script to kick start a new project using project-init -
function sb_init {
local RED="\033[0;31m"
local NC="\033[0m"
if [ ! $# == 1 ]; then
echo -e "${RED}Please specify a project name, or action (update, revert).${NC}"
echo -e "Usage: init project-name / action\n"
elif [ "$1" == "--update"]; then
local name=$(node -e "console.log(require('./package.json').name)");
mv package.json package.bak.json;
mv node_modules node_modules_bak;
curl -sSOL;
sed -i.tmp "s/Project-Name/$name/g" package.json;
rm package.json.tmp;
npm install;
elif [ "$1" == "--revert"]; then
if [ -e node_modules_bak -a -e package.bak.json ]; then
rm -r node_modules;
rm package.json;
mv node_modules_bak node_modules;
mv package.bak.json package.json;
echo -e "${RED}Downloading project-init${NC} 🚀\n"
curl -s -S -O -L;
echo -e "${RED}Download finished.${NC}\n"
echo -e "${RED}Setting up project config files.${NC}\n"
unzip -qq;
mv project-init-master $1
sed -i.bak "s/Project-Name/$1/g" $1/package.json;
rm $1/package.json.bak;
sed -i.bak "s/Project-Name/$1/g" $1/.rvmrc;
rm $1/.rvmrc.bak;
cd $1
npm install;
echo -e "${RED}Your project is all ready to go. Enjoy${NC}\n"
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.