Last Updated: February 25, 2016
·
898
· phaus

node.js project setup Script

Inspired by http://stackoverflow.com/questions/5178334/folder-structure-for-a-nodejs-project

Usage

Usage: ./createNodeProject <folder> [default|application|coffee]

default     -   for default node.js project.
application -   for MVC- / ORM-Framework like express or mongoose.
coffee      -   for CoffeeScript-based Express applications (using connect-assets).

#!/bin/bash
if [ $# -ne 2 ]; then
    echo ""
    echo "Usage: ./createNodeProject <folder> [default|application|coffee]"
    echo ""
    echo "default       -   for default node.js project."
    echo "application   -   for MVC- / ORM-Framework like express or mongoose."
    echo "coffee        -   for CoffeeScript-based Express applications (using connect-assets)."
    echo ""     
    exit 1
else
    ROOT=$1
    TYPE=$2

    if [ $TYPE == "default" ]; then
        FOLDERS=( "lib" "vendor" "spec" "tests" )
    fi

    if [ $TYPE == "application" ]; then
        FOLDERS=( "lib" "vendor" "spec" "tests" "models" "views" "public/img" "public/css" "public/js" "controllers" )
    fi

    if [ $TYPE == "coffee" ]; then
        FOLDERS=( "lib" "vendor" "spec" "tests" "app" "public/img" "public/css" "public/js" "assets/js" "assets/css" "src" "views" )
    fi

    for f in ${FOLDERS[@]}
    do
        mkdir -p $ROOT/$f
    done
    exit 0
fi