Last active
March 20, 2018 00:50
-
-
Save polypus74/c78648e1b286dec8ce28c0cfcf714a00 to your computer and use it in GitHub Desktop.
Create new sbt project with git & ensime setup
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/bin/bash | |
DEFAULT_TEMPLATE="sbt/scala-seed.g8" | |
function err { | |
echo "error: $1, exiting." | |
exit 1 | |
} | |
if [[ -z "$1" ]] | |
then err "must supply project name as first argument" | |
elif [[ -e "$1" ]] | |
then err "$1 already exists" | |
elif [[ -e target ]] | |
then err "target file or dir exists in $PWD" | |
fi | |
START_DIR="$PWD" | |
PROJECT="$1" | |
function cleanup { | |
cd "$START_DIR" | |
rm -rf ./target "./$PROJECT" | |
err "aborting" | |
} | |
trap cleanup SIGINT SIGTERM | |
echo "$PROJECT" | sbt new ${2:-${DEFAULT_TEMPLATE}} | |
if [[ -e "./$PROJECT" ]] | |
then cd "./$PROJECT" | |
sbt ensimeConfig | |
git init | |
echo 'target/' > .gitignore | |
cd .. | |
fi | |
rm -rf ./target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment