Skip to content

Instantly share code, notes, and snippets.

@SuperstrongBE
Last active August 29, 2015 14:19
Show Gist options
  • Save SuperstrongBE/10e0a22f481f978b7170 to your computer and use it in GitHub Desktop.
Save SuperstrongBE/10e0a22f481f978b7170 to your computer and use it in GitHub Desktop.
A simple Shell that scaffold an angular module folder

Angular module Scaffhold shell

Because i'm soooooo lazy i've made a shell to create angular module folder structure. Inside your modules folder, simply run /module.sh -m MyCoolModuleName

##Flags ####-m specify module name angular.module('ModuleName',[])
default value: module

####-a specify application name to have module bootstrpa like angular.module('AppName.ModuleName',[]) if you don't like leave it!
optional

#!/bin/bash
verbose='false'
appName=''
moduleName='module'
while getopts 'a:v m:v' flag;
do
case ${flag} in
a) appName=${OPTARG}.;;
m) moduleName=${OPTARG};;
esac
done
if [ -d $moduleName ];then
echo "OUPS: Sorry this module already exists " 1>&2
exit 0
fi
if [ ! -d $moduleName ];then
echo "Process: Creating your module! " 1>&2
moduleDirectories=( directives controllers providers )
moduleFiles=(".run.js" ".config.js" ".constants.js")
mkdir $moduleName
echo "angular.module('$appName$moduleName',[])">>"$moduleName/$moduleName.module.js"
for FILE in ${moduleFiles[@]};
do
echo "angular.module('$appName$moduleName')">>"$moduleName/$moduleName$FILE"
done
echo $moduleName
for DIR in ${moduleDirectories[@]};
do
mkdir "$moduleName/$DIR"
mkdir "$moduleName/$DIR/prototypes"
done
echo "Owwyeah: Your module is ready to use! " 1>&2
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment