diff --git a/lib/exe.js b/lib/exe.js index 54d2f63..022ada9 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -643,7 +643,7 @@ function _monkeyPatchMainCc(compiler, complete) { function (content) { return ~content.indexOf('// // TODO use parse opts'); }, - function (content, next) { + function (content, next) { // TODO: failsafe this var lines = content.split('\n'); var endLine = lines.indexOf(' option_end_index = i;'); // pre node 0.11.6 compat @@ -713,6 +713,12 @@ SetFlagsFromString(nexevargs, nexevargslen);\n\ lineToInjectAfter = contentsSplit.indexOf('#undef FLAG_MODE_DEFINE_IMPLICATIONS'); } + // support for 0.10.x + if(lineToInjectAfter===-1) { + _log('warn', '0.12.x patch failed. Trying 0.10.0 patch'); + lineToInjectAfter = contentsSplit.indexOf('#define FLAG_MODE_DEFINE_IMPLICATIONS')+1; + } + // this is debug, comment out. // _log('v8 injection is', injectionLength, 'newlines long'); // _log('v8 flags source is', contentsLength, 'newlines long'); @@ -755,7 +761,7 @@ SetFlagsFromString(nexevargs, nexevargslen);\n\ finalContents = finalContents.replace(/const char\* nexevargs = "[A-Z\-\_]*";/gi, 'const char* nexevargs = "'+options.jsFlags+'";'); } else { - _log('warn', 'failed to find a suitable injection point for v8 args.', + _log('error', 'failed to find a suitable injection point for v8 args.', 'File a bug report with the node version and log.'); _log('lineToInjectAfter='+lineToInjectAfter, 'haveWeInjectedBefore='+haveWeInjectedBefore); @@ -766,6 +772,7 @@ SetFlagsFromString(nexevargs, nexevargslen);\n\ finalContents = contentsSplit.join('\n'); } + // write the file contents fs.writeFile(mainPath, finalContents, {encoding: 'utf8'}, function(err) { if(err) { _log('error', 'failed to write to', mainPath);