Skip to content

Instantly share code, notes, and snippets.

@oimou
Created August 25, 2015 16:14
Show Gist options
  • Select an option

  • Save oimou/05e6e12a0c142173b0b3 to your computer and use it in GitHub Desktop.

Select an option

Save oimou/05e6e12a0c142173b0b3 to your computer and use it in GitHub Desktop.
var patcher = require("virtual-patch");
var diff = "diff string here";
patcher.patch(
// pass diff string of git style
diff,
// read a file of given filename
function readFile(filename, cb) {
someAsyncRead(filename, function (err, data) {
cb(err, data);
});
},
// write content to a file of given filename
function writeFile(filename, content, cb) {
someAsyncWrite(filename, content, function (err) {
cb(err);
});
},
// remove a file of given filename
function unlink(filename, cb) {
someAsyncUnlink(filename, function (err) {
cb(err);
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment