Skip to content

Instantly share code, notes, and snippets.

@anselmbradford
Last active August 29, 2015 14:21
Show Gist options
  • Save anselmbradford/1b87ecfda21325bb37dc to your computer and use it in GitHub Desktop.
Save anselmbradford/1b87ecfda21325bb37dc to your computer and use it in GitHub Desktop.
frontendbuild.sh experiment
#!/bin/sh
# Set script to exit on any errors.
set -e
# Initialize project dependency directories.
init(){
NODE_DIR=node_modules
BOWER_DIR=bower_components
if [ -f .bowerrc ]; then
# Get the "directory" line from .bowerrc
BOWER_DIR=$(grep "directory" .bowerrc | cut -d '"' -f 4)
fi
echo 'npm components directory:' $NODE_DIR
echo 'Bower components directory:' $BOWER_DIR
}
# Clean project dependencies.
clean(){
# If the node and bower directories already exist,
# clear them so we know we're working with a clean
# slate of the dependencies listed in package.json
# and bower.json.
if [ -d $NODE_DIR ] || [ -d $BOWER_DIR ]; then
echo 'Removing project dependency directories...'
rm -rf $NODE_DIR
rm -rf $BOWER_DIR
fi
echo 'Project dependencies have been removed.'
}
# Install project dependencies.
install(){
echo 'Installing project dependencies...'
npm install
bower install --config.interactive=false
}
# Run tasks to build the project for distribution.
build(){
echo 'Building project...'
grunt build
}
init
clean
install
build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment