Skip to content

Instantly share code, notes, and snippets.

@hughsk
Created April 3, 2012 09:45
Show Gist options
  • Save hughsk/2290728 to your computer and use it in GitHub Desktop.
Save hughsk/2290728 to your computer and use it in GitHub Desktop.
Node + Git push-to-deploy hook
# GITBAREDIR e.g. "/home/web/present-company.git"
GITBAREDIR=`pwd`;
# GITPROJECTDIR e.g. "present-company"
GITPROJECTDIR=`basename $PWD | sed 's/.git//g'`;
# Stop the application, move up on directory
npm stop;
cd ..;
# Clears the working app directory
# Careful with this one!
sudo rm $GITPROJECTDIR --recursive;
# Clone new contents of project directory, e.g.
# Bare directory: ./present-company.git
# Working App: ./present-company
git clone $GITBAREDIR $GITPROJECTDIR;
# Go to the new project directory and install dependencies
cd $GITPROJECTDIR && sudo npm install .;
# Start the application again.
npm start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment