Last active
September 8, 2016 02:28
-
-
Save jesseditson/45c604bfe66a6bed0a0fa0a1359caf4b to your computer and use it in GitHub Desktop.
Deploy using now without all the local cruft
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 | |
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