Skip to content

Instantly share code, notes, and snippets.

@AmrAbdulrahman AmrAbdulrahman/npm.sh Secret
Created Mar 21, 2016

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.