move utils to their own file

This commit is contained in:
Craig Condon
2014-02-28 10:39:13 -08:00
parent 9f93ac0e1e
commit c583e2f029
6 changed files with 65 additions and 49 deletions
+32
View File
@@ -0,0 +1,32 @@
var async = require("async"),
fs = require("fs");
module.exports = _monkeypatch;
/**
*/
function _monkeypatch (filePath, monkeyPatched, processor, complete) {
async.waterfall([
function read (next) {
fs.readFile(filePath, "utf8", next);
},
// TODO - need to parse gyp file - this is a bit hacker
function monkeypatch (content, next) {
if (monkeyPatched(content)) return complete();
_log("monkey patch %s", filePath);
processor(content, next);
},
function write (content, next) {
fs.writeFile(filePath, content, "utf8", next);
}
], complete);
}