Skip to content

Instantly share code, notes, and snippets.

@ezekg
Last active May 16, 2016 18:36
Show Gist options
  • Save ezekg/0c4fe0f3cf467ad3fcfb246c301125c2 to your computer and use it in GitHub Desktop.
Save ezekg/0c4fe0f3cf467ad3fcfb246c301125c2 to your computer and use it in GitHub Desktop.
Simple bash task runner
#!/usr/bin/env bash
# Run a task
#
# @param $1 - Task name
# @param $2 - Command to run
function task() {
printf "\033[00;34m%-50s\033[0m" "$1 ..."
eval "$2" && success || fail
}
# Print success message
function success {
echo -e "\033[00;32m[ OK ]\033[0m"
}
# Print failure message
function fail {
echo -e "\033[00;31m[ FAIL ]\033[0m"
}
# Tasks
task "Creating asset folder" "mkdir -p www/public/assets > /dev/null 2>&1"
task "Copying assets" "cp -R src/assets/* www/public/assets/ > /dev/null 2>&1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment