Skip to content

Instantly share code, notes, and snippets.

@jesseditson
Last active September 8, 2016 02:28
Show Gist options
  • Save jesseditson/45c604bfe66a6bed0a0fa0a1359caf4b to your computer and use it in GitHub Desktop.
Save jesseditson/45c604bfe66a6bed0a0fa0a1359caf4b to your computer and use it in GitHub Desktop.
Deploy using now without all the local cruft
#!/bin/bash
set -e
if [ -z "$(which now)" ]; then
echo "please install now to use this script."
exit 1
fi
# remove common build folders if they are ignored
if [ -e ".gitignore" ]; then
[ -n "$(cat .gitignore | grep dev)" ] && rm -rf dev
[ -n "$(cat .gitignore | grep dist)" ] && rm -rf dist
fi
if [ -e ".ember-cli" ]; then
# looks like an ember app, build for prod
ember build --environment=production
fi
# remove
node -e "var p = require('./package.json'); delete p.devDependencies; require('fs').writeFileSync('package.prod.json', JSON.stringify(p, null, 2), 'utf-8');";
mv package.json _package.json
mv package.prod.json package.json
function finish {
mv _package.json package.json
}
trap finish EXIT
# nuke tmp so we don't deploy a bunch of garbage
rm -rf tmp
now
REALIAS=$(which now-realias)
if [ -z "$REALIAS" && -n "$1" ]; then
now alias $(pbpaste) $1
else if [ -z "$REALIAS" ]; then
echo "Deployed. If you would like to re-alias automatically, either install now-realias or pass the domain as the first argument."
else
now-realias
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment