From 75932723ac4c233a5daa146c952ba9c12ca89ad0 Mon Sep 17 00:00:00 2001 From: Adam Snodgrass Date: Fri, 28 Feb 2014 18:54:38 -0600 Subject: [PATCH 1/2] Added progress to package.json dependencies; Defined _log in monkeypatch.js --- lib/monkeypatch.js | 2 ++ package.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/monkeypatch.js b/lib/monkeypatch.js index 0e78562..da31add 100644 --- a/lib/monkeypatch.js +++ b/lib/monkeypatch.js @@ -1,6 +1,8 @@ var async = require("async"), fs = require("fs"); +var _log = require('./log'); + module.exports = _monkeypatch; diff --git a/package.json b/package.json index 8a03ba9..159d8b8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "sardines": "~0.4.5", "async": "~0.2.10", "colors": "~0.6.2", - "glob": "~3.2.9" + "glob": "~3.2.9", + "progress": "~1.1.3" }, "preferGlobal": "true", "bin": { From d4e62c668e660886985a0e31582d9ebaef7a10f8 Mon Sep 17 00:00:00 2001 From: Adam Snodgrass Date: Fri, 28 Feb 2014 21:16:38 -0600 Subject: [PATCH 2/2] Add option to disable node and v8 flags and pass through app flags --- bin/nexe | 6 ++++++ lib/exe.js | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/bin/nexe b/bin/nexe index 8f9f7ac..960e5c7 100755 --- a/bin/nexe +++ b/bin/nexe @@ -26,6 +26,11 @@ options('t', { default: '/tmp/nexe', description: 'The path to store node.js sources' }). +options('f', { + alias: 'flags', + description: 'Don\'t parse node and v8 flags, pass through app flags', + default: false +}). options('v', { alias: 'version', description: 'Display version number' @@ -54,6 +59,7 @@ function toRelative(pt) { require('../lib').compile({ input : toRelative(argv.i), output : toRelative(argv.o), + flags : argv.f, nodeVersion : argv.r, nodeTempDir : toRelative(argv.t) }, function(error) { diff --git a/lib/exe.js b/lib/exe.js index 133604b..78c583a 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -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; @@ -61,6 +61,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 */ @@ -221,6 +232,7 @@ function _monkeyPatchNodeConfig (compiler, complete) { function (next) { _monkeyPatchMainJs(compiler, next) } + ], complete); } @@ -261,6 +273,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 + ); +} + /** */