Skip to content

Instantly share code, notes, and snippets.

@AmrAbdulrahman
Created March 21, 2016 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmrAbdulrahman/7c24ec3afb1319a3e782 to your computer and use it in GitHub Desktop.
Save AmrAbdulrahman/7c24ec3afb1319a3e782 to your computer and use it in GitHub Desktop.
#!/bin/bash
# NOTE: You need to set NPM_REMOTE_USER and NPM_REMOTE before running this script
# execute <npm command args..> on remote server
ssh "$NPM_REMOTE_USER"@"$NPM_REMOTE" ./npm.sh "$1" "$2" "$3" "$4"
# if command is [install, i, uninstall, un or prune] then sync node_modules and package.json
if [ "$1" == 'i' ] || [ "$1" == 'install' ] || [ "$1" == 'un' ] || [ "$1" == 'uninstall' ] || [ "$1" == 'prune' ]
then
# sync node_modules/
rsync -r "$NPM_REMOTE_USER"@"$NPM_REMOTE":~/remote-node-modules/node_modules/ node_modules
# sync package.json
rsync "$NPM_REMOTE_USER"@"$NPM_REMOTE":~/remote-node-modules/package.json package.json
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment