Last active
September 18, 2017 19:16
-
-
Save edirpedro/0bfadc47f95e4b5f20860777a0994a11 to your computer and use it in GitHub Desktop.
Gulp Quick Start Tool
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
#!/bin/bash | |
# Gulp Quick Start Tool | |
# | |
# Starts a gulp watch checking if NPM and dependencies are installed. | |
# Just put this file next to package.json and gulpfile.js, then double click on it to run. | |
# This file has to be executable: chown +x gulp.tool | |
# | |
# author: Edir Pedro | |
# email: [email protected] | |
# website: https://gist.github.com/edirpedro/0bfadc47f95e4b5f20860777a0994a11 | |
function say { | |
echo "$(tput sgr0)- - - - - - - - - - - - - - - - - - - - - - -" | |
printf "$(tput setaf 3)$1\n"; | |
echo "$(tput sgr0)- - - - - - - - - - - - - - - - - - - - - - -" | |
} | |
# Open current directory | |
cd "$(dirname "$0")" | |
# Node JS is installed? | |
if ! type npm > /dev/null; then | |
say "Node JS not installed!\nGet the LTS version from http://nodejs.org" | |
exit 1 | |
fi | |
# If node_modules folder does not exists then try to install | |
if ! [ -d "node_modules" ]; then | |
# If package.json exists then install dependencies | |
if [ -e "package.json" ]; then | |
say "Trying to install NPM dependencies." | |
npm install | |
else | |
say "File package.json was not found!\nAsk the developer to write one." | |
exit 1 | |
fi | |
fi | |
# Execute watch task | |
if [ -e "gulpfile.js" ]; then | |
say "Running watch task" | |
gulp watch | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment