From 16139e1dc71c6fe11934bbc29c19775a6b97e17d Mon Sep 17 00:00:00 2001 From: vilicvane Date: Wed, 21 Oct 2015 17:59:38 +0800 Subject: [PATCH 1/6] Fix a bug caused by last line being a `//` comment Such as `//# sourceMappingURL=...`. --- lib/bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundle.js b/lib/bundle.js index d18b2f6..e0daf7a 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -122,7 +122,7 @@ function bundle (input, complete) { dep.source = '//' + dep.source; } - req += dep.source + "}"; + req += dep.source + "\n}"; dbuffer.push(JSON.stringify(dep.id) + ": ["+req+", "+!!dep.entry+", "+JSON.stringify(dep.deps)+"]") } From 002727e10fcea5de54cb99234066ade6f7154e73 Mon Sep 17 00:00:00 2001 From: vilicvane Date: Thu, 22 Oct 2015 14:45:30 +0800 Subject: [PATCH 2/6] proxy browserResolve for better compatibility; fix node bad option error; change process.argv[1] to current module path for commander.js compatibility. --- lib/bundle.js | 15 +++++++++++---- lib/exe.js | 10 ++++++++-- package.json | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/bundle.js b/lib/bundle.js index e0daf7a..65090d0 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -21,10 +21,11 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **/ -var mdeps = require("module-deps"), -through = require("through"), -async = require("async"), -builtins = require("builtins"); +var mdeps = require("module-deps"), +browserResolve = require("browser-resolve"), +through = require("through"), +async = require("async"), +builtins = require("builtins"); var _log = require("./log"); @@ -43,6 +44,10 @@ function bundle (input, complete) { var md = mdeps({ + resolve: function (id, options, callback) { + options.browser = "main"; + return browserResolve(id, options, callback); + }, xtransform: function (tr, file) { var buffer = []; @@ -140,6 +145,8 @@ var loader = function (deps, key) { var darr = []; var dir = global.require("path").dirname(process.execPath); + process.argv[1] = key; + var argv3 = process.argv[3]; if (argv3) { argv3 = pathModule.relative(pathModule.dirname(process.execPath), argv3); diff --git a/lib/exe.js b/lib/exe.js index 142af42..f4d4d75 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -555,7 +555,13 @@ function _monkeyPatchMainJs (compiler, complete) { return ~content.indexOf("nexe"); }, function (content, next) { - next(null, content.replace(/\(function\(process\) \{/,'(function(process) {\n process._eval = \'require("nexe");\';\n process.argv.splice(1, 0, "nexe.js");\n')) + next(null, content.replace(/\(function\(process\) \{/,'\ +(function(process) {\n\ + process._eval = \'require("nexe");\';\n\ + if (process.argv[1] !== "nexe.js") {\n\ + process.argv.splice(1, 0, "nexe.js");\n\ + }\n\ +')) }, complete ); @@ -572,7 +578,7 @@ function _monkeyPatchChildProcess(compiler, complete) { return ~content.indexOf("--child_process"); }, function (content, next) { - next(null, content.replace(/return spawn\(/, 'args.unshift("--child_process");\n return spawn(')); + next(null, content.replace(/return spawn\(/, 'args.unshift("nexe.js", "--child_process");\n return spawn(')); }, complete ); diff --git a/package.json b/package.json index 23bef7a..5854ea3 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "main": "./lib/index.js", "dependencies": { "async": "1.2.1", + "browser-resolve": "^1.10.0", "builtins": "1.0.1", "colors": "^1.0.3", "glob": "^5.0.5", @@ -43,7 +44,7 @@ "ignoreFlags": true } }, - "preferGlobal": "true", + "preferGlobal": true, "bin": { "nexe": "./bin/nexe" } From 915181d0b085be183177e8bdd5d4fe4ed18fecf4 Mon Sep 17 00:00:00 2001 From: vilicvane Date: Fri, 23 Oct 2015 12:21:41 +0800 Subject: [PATCH 3/6] Do not change --child_process path if it's absolute --- lib/bundle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundle.js b/lib/bundle.js index 65090d0..233036d 100644 --- a/lib/bundle.js +++ b/lib/bundle.js @@ -143,12 +143,12 @@ function bundle (input, complete) { var loader = function (deps, key) { var pathModule = global.require("path"); var darr = []; - var dir = global.require("path").dirname(process.execPath); + var dir = pathModule.dirname(process.execPath); process.argv[1] = key; var argv3 = process.argv[3]; - if (argv3) { + if (argv3 && /^(?!\/|\w+:)/.test(argv3)) { argv3 = pathModule.relative(pathModule.dirname(process.execPath), argv3); argv3 = pathModule.resolve(pathModule.dirname(key), argv3); } From de531ba750f1434e8c40cfd84b131843fcaf3ffd Mon Sep 17 00:00:00 2001 From: borislav nikolov Date: Thu, 5 Nov 2015 15:13:58 +0100 Subject: [PATCH 4/6] add nodeConfigureArgs and nodeMakeArgs from package.json example: "runtime": { "framework": "nodejs", "version": "5.0.0", "ignoreFlags": true, "nodeConfigureArgs": ["--fully-static"], "nodeMakeArgs": ["-j","4"] } there is no check if those flags change, which means if they are changed you must rm -rf the temp directory will probably push a commit that writes a checksum of them in the node temp directory so it knows when it is invalid --- lib/exe.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/exe.js b/lib/exe.js index f4d4d75..b2114d5 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -138,7 +138,7 @@ exports.compile = function (options, complete) { * first download node */ function downloadNode (next) { - _downloadNode(version, options.nodeTempDir, next); + _downloadNode(version, options.nodeTempDir, options.nodeConfigureArgs, options.nodeMakeArgs, next); }, /** @@ -289,14 +289,14 @@ exports.compile = function (options, complete) { * @param {function} complete, callback */ -function _downloadNode (version, directory, complete) { +function _downloadNode (version, directory, nodeConfigureArgs, nodeMakeArgs, complete) { var nodeFileDir = path.resolve(path.join(directory, framework, version)), // fixes #107, was process.cwd(), + rest. nodeFilePath = path.resolve(path.join(nodeFileDir, framework + "-" + version + ".tar.gz")); // might already be downloaded, and unzipped - if (_getNodeCompiler(nodeFileDir, complete)) { + if (_getNodeCompiler(nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complete)) { return; } @@ -373,7 +373,7 @@ function _downloadNode (version, directory, complete) { */ function (next, type) { - _getNodeCompiler(nodeFileDir, next, type) + _getNodeCompiler(nodeFileDir, nodeConfigureArgs, nodeMakeArgs, next, type) }, ], complete); @@ -384,7 +384,7 @@ function _downloadNode (version, directory, complete) { * it. */ -function _getNodeCompiler (nodeFileDir, complete, type) { +function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complete, type) { var dir = _getFirstDirectory(nodeFileDir); // standard @@ -432,9 +432,9 @@ function _getNodeCompiler (nodeFileDir, complete, type) { make: function (next) { var cfg = "./configure", configure; if(isPy !== "python") { - configure = spawn(isPy, [cfg], { cwd: dir }); + configure = spawn(isPy, [cfg].concat(nodeConfigureArgs), { cwd: dir }); } else { - configure = spawn(cfg, [], { cwd: dir }); + configure = spawn(cfg, nodeConfigureArgs, { cwd: dir }); } // local function, move to top eventually @@ -486,7 +486,7 @@ function _getNodeCompiler (nodeFileDir, complete, type) { if (os.platform().match(/bsd$/) != null) { platformMake = "gmake"; } - var make = spawn(platformMake, [], { cwd: dir }); + var make = spawn(platformMake, nodeMakeArgs, { cwd: dir }); make.stdout.pipe(process.stdout); make.stderr.pipe(process.stderr); make.on("close", function () { @@ -698,6 +698,8 @@ exports.package = function(path, options) { input: (_package.nexe.input || options.i), output: (_package.nexe.output || options.o), flags: (_package.nexe.runtime.ignoreFlags || options.f), + nodeConfigureArgs: (_package.nexe.runtime.nodeConfigureArgs || []), + nodeMakeArgs: (_package.nexe.runtime.nodeMakeArgs || []), resourceFiles: (_package.nexe.resourceFiles), nodeVersion: (_package.nexe.runtime.version || options.r), python: (_package.nexe.python || options.p), From 907be00fdc4445077ea6d5a3e35b78251efd9ec0 Mon Sep 17 00:00:00 2001 From: Jamie Chard Date: Thu, 12 Nov 2015 15:56:29 +1100 Subject: [PATCH 5/6] Make checkThatExecutableExists backwards compatible --- lib/exe.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/exe.js b/lib/exe.js index b2114d5..11cdd83 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -248,8 +248,8 @@ exports.compile = function (options, complete) { */ function checkThatExecutableExists (next) { - fs.access(nodeCompiler.releasePath, function (err) { - if (err) { + fs.exists(nodeCompiler.releasePath, function (exists) { + if (!exists) { _log("error", "The release executable has not been generated. " + "This indicates a failure in the build process. " + From 53a9c5a210df733ffc832f7966124463acdcd186 Mon Sep 17 00:00:00 2001 From: Jared Allard Date: Mon, 30 Nov 2015 13:24:11 -0800 Subject: [PATCH 6/6] breaking changes notification --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2bf503d..1b64b10 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![Join the chat at https://gitter.im/crcn/nexe](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/crcn/nexe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Dependency Status](https://david-dm.org/crcn/nexe.svg)](https://david-dm.org/crcn/nexe) [![Stories in Ready](https://badge.waffle.io/crcn/nexe.svg?label=ready&title=Ready)](http://waffle.io/crcn/nexe) +# NOTICE: Node 5.x.x is broken right now. + Nexe is a command-line utility that compiles your Node.js application into a single executable file. ![screen shot 2014-02-28 at 10 32 54 am](https://f.cloud.github.com/assets/757408/2296993/c276f7b6-a0a6-11e3-86d3-e6c5feba2a85.png)