move utils to their own file
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user