Merge pull request #44 from northshorenetworks/master
Add option to pass through CLI flags but ignore node and v8 flags
This commit is contained in:
+41
-1
@@ -9,7 +9,7 @@ ProgressBar = require("progress"),
|
||||
child_process = require("child_process"),
|
||||
glob = require("glob"),
|
||||
sardines = require("sardines"),
|
||||
os = require("os"),
|
||||
os = require("os"),
|
||||
spawn = child_process.spawn;
|
||||
|
||||
|
||||
@@ -63,6 +63,17 @@ exports.compile = function (options, complete) {
|
||||
_monkeyPatchNodeConfig(nodeCompiler, next);
|
||||
},
|
||||
|
||||
/**
|
||||
* monkeypatch node.cc to prevent v8 and node from processing CLI flags
|
||||
*/
|
||||
function monkeyPatchNodeCc (next) {
|
||||
if (options.flags) {
|
||||
_monkeyPatchMainCc(nodeCompiler, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* compile the node application
|
||||
*/
|
||||
@@ -223,6 +234,7 @@ function _monkeyPatchNodeConfig (compiler, complete) {
|
||||
function (next) {
|
||||
_monkeyPatchMainJs(compiler, next)
|
||||
}
|
||||
|
||||
], complete);
|
||||
}
|
||||
|
||||
@@ -263,6 +275,34 @@ function _monkeyPatchMainJs (compiler, complete) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
function _monkeyPatchMainCc(compiler, complete) {
|
||||
var mainPath = path.join(compiler.dir, "src", "node.cc");
|
||||
_monkeypatch(
|
||||
mainPath,
|
||||
function (content) {
|
||||
return ~content.indexOf('// // TODO use parse opts');
|
||||
},
|
||||
function (content, next) {
|
||||
var lines = content.split('\n');
|
||||
/* These lines exist until v0.11.6 */
|
||||
var startLine = lines.indexOf(' // TODO use parse opts');
|
||||
var endLine = lines.indexOf(' option_end_index = i;');
|
||||
|
||||
for (var i = startLine; i < endLine; i++) {
|
||||
lines[i] = '//' + lines[i];
|
||||
}
|
||||
|
||||
lines[endLine] = ' option_end_index = 1;';
|
||||
lines = lines.join('\n');
|
||||
next(null, lines);
|
||||
},
|
||||
complete
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ var async = require("async"),
|
||||
fs = require("fs"),
|
||||
_log = require("./log");
|
||||
|
||||
var _log = require('./log');
|
||||
|
||||
module.exports = _monkeypatch;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user