#!/bin/bash
BASE="$(cd `dirname "$0"` && pwd)"

main () {
    local cmd="$1"
    case $cmd in
        'setup')
            shift
            setup "$@"
            ;;
        'test')
            shift
            run_tests "$@"
            ;;
        'clean')
            shift
            clean "$@"
            ;;
        * )
            echo "
Exiting without running any operations.
Possible operations include:

  setup - Install dependencies.
    Usage: ./manage.sh setup

  test - Run tests.
    Usage: ./manage.sh test

  clean - Remove everything generated by this script.
    Usage: ./manage.sh clean
            "
            ;;
    esac
}

setup () {
    if ! [ -d "$BASE/node_modules" ]; then
        cd "$BASE/"
        mkdir "$BASE/node_modules"
        npm install
    else
        echo "npm modules already installed ..."
    fi
}

run_tests () {
    setup
    node $BASE/management/run_globals_test.js test/
    node $BASE/management/run_tests.js test/
}

clean () {
    rm -rf "$BASE/node_modules/"
    echo "removed ./node_modules/"
}

main "$@"

#!/bin/bash
BASE="$(cd `dirname "$0"` && pwd)"

main () {
    local cmd="$1"
    case $cmd in
        'setup')
            shift
            setup "$@"
            ;;
        'test')
            shift
            run_tests "$@"
            ;;
        'clean')
            shift
            clean "$@"
            ;;
        * )
            echo "
Exiting without running any operations.
Possible operations include:

  setup - Install dependencies.
    Usage: ./manage.sh setup

  test - Run tests.
    Usage: ./manage.sh test

  clean - Remove everything generated by this script.
    Usage: ./manage.sh clean
            "
            ;;
    esac
}

setup () {
    if ! [ -d "$BASE/node_modules" ]; then
        cd "$BASE/"
        mkdir "$BASE/node_modules"
        npm install
    else
        echo "npm modules already installed ..."
    fi
}

run_tests () {
    setup
    node $BASE/management/run_globals_test.js test/
    node $BASE/management/run_tests.js test/
}

clean () {
    if [ -d "$BASE/node_modules" ]; then
        rm -rf "$BASE/node_modules"
        echo "removed ./node_modules/"
    fi
    if [ -d /etc/enginemill ]; then
        sudo rm -rf /etc/enginemill
        echo "removed /etc/enginemill"
    fi
    if [ -d "$HOME/.enginemill" ]; then
        sudo rm -rf "$HOME/.enginemill"
        echo "removed $HOME/.enginemill"
    fi
    echo "Done. Cleaned."
}

main "$@"

Add settings test fixture cleanup
Add settings test fixture cleanup

 On branch master

	modified:   manage.sh
