live-patch
patch the source code of a running program
Currently this module is nothing more than cheap parlor tricks.
Whether any module claiming these features can ever be more than flimsy cardboard is an open question.
example
First whip up a patch.js to monitor a program.js file for changes:
var fs = ;var gaze = ;var file = __dirname + '/program.js';var patch = ;;;{fs;}
run patch.js and then then edit program.js
live and watch the output.
methods
var patch =
var p = patch(src)
Create a patch instance p
, optionally with some source code src
.
p.update(src)
Set the source code to src
, updating the running state as necessary.
usage
This package comes with a command-line tool.
live-patch {OPTIONS} FILE [ARGS...]
Run FILE with node, watching for changes.
When FILE changes, the new source is patched in.
-h --help Show this message.
todo
I'm not especially keen to develop this prototype much further, but if somebody wants, these features would lead to a more robust tool:
- create a dependency graph for AST updates - when you update
var x
, you also implicitly updatevar y = x + 10
and so on.
As it stands this demo is already pushing the limits of what undisciplined AST trickery is reasonably capable of.
install
With npm do:
npm install live-patch
to get the library or
npm install -g live-patch
to get the command-line tool.
license
MIT