Automatic App Deployment with “git push”
When deploying pet projects on remote servers, I dislike the extra step of logging into the remote machine to execute a git pull
(and perhaps a server reload) every time I push new code. Sure there’s Jenkins and all sorts of bazooka-like solutions, but this is a knife fight. Poking around an old PHP repo, I found a nifty line of code that will update your app via a URL endpoint.
Play it Again, Sam: Reloading Node.js modules

Reloading modules in Node.js can be a bit tricky. After initially importing a module, subsequent calls to require
have no effect. Looking for something along the lines of Python’s reload
command I’ve arrived at this solution that allows modules to be reloaded (as well as imported the first time) with the following require.reload
command.
// Import a module
var mymodule = require('./mymodule')
// After making some changes to the module, reload it
mymodule = require.reload('./mymodule')
Reloading is accomplished by searching the cache for a specific module using require.searchCache
and removing that module and its children with require.uncache
. The real heavy lifting is done by the call to delete require.cache[mod.id]
. Below is the script for starting a modified repl that includes the additional require commands by default.