From 6ff539b4e64d362301d57edc76ac437c08bd0b7a Mon Sep 17 00:00:00 2001 From: Alex Whitman Date: Sat, 17 Aug 2013 10:31:55 +0100 Subject: [PATCH 1/4] Fix up linting warnings - Mix of tabs and spaces - Trailing whitepsace - Missing semi-colons --- lib/index.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/index.js b/lib/index.js index 47aac10..2b7750c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -60,20 +60,20 @@ exports.compile = function(args, next) { * 5. bundle it all together */ - on.success(function() { - console.log("building node.js"); - this.node.make(this); - }), + on.success(function() { + console.log("building node.js"); + this.node.make(this); + }), - /** - * 6. copy the executable - */ + /** + * 6. copy the executable + */ - on.success(function() { - console.log("copying binary to output directory to %s", args.output); + on.success(function() { + console.log("copying binary to output directory to %s", args.output); - mkdirp(path.dirname(args.output), this); - }), + mkdirp(path.dirname(args.output), this); + }), /** */ @@ -87,8 +87,8 @@ exports.compile = function(args, next) { next - ) -} + ); +}; /** */ @@ -100,7 +100,7 @@ function downloadNode(version, next) { try { - mkdirp.sync(path.dirname(tmpPath)) + mkdirp.sync(path.dirname(tmpPath)); //an error will usually occur when the dir already exists. } catch(e) { } @@ -164,7 +164,7 @@ function downloadNode(version, next) { make: function(next) { var proc = exec(sprintf("cd %s; ./configure; make; ", srcDr)); proc.stdout._events = {}; //remove stdout & stdin capture - proc.stdin._events = {}; + proc.stdin._events = {}; proc.stdout.on("data", function(chunk) { process.stdout.write(chunk); }); @@ -207,7 +207,7 @@ function monkeyPatchNodejs(node, next) { //nexe already injected? if(~content.indexOf('nexe')) return this(); - fs.writeFile(nodejsPath, + fs.writeFile(nodejsPath, content.replace(/\(function\(process\) \{/,'(function(process){ \n process._eval = \'require("nexe");\'; '), "utf8", this); @@ -241,4 +241,4 @@ function monkeyPatchNodejs(node, next) { next ); -} \ No newline at end of file +} From b2871f09cdf4b3930d7a206da831729b7179722f Mon Sep 17 00:00:00 2001 From: Alex Whitman Date: Sat, 17 Aug 2013 11:36:03 +0100 Subject: [PATCH 2/4] Rewrite configure/make spawning --- lib/index.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2b7750c..7f3a6a0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -162,17 +162,23 @@ function downloadNode(version, next) { //makes node.js make: function(next) { - var proc = exec(sprintf("cd %s; ./configure; make; ", srcDr)); - proc.stdout._events = {}; //remove stdout & stdin capture - proc.stdin._events = {}; - proc.stdout.on("data", function(chunk) { - process.stdout.write(chunk); + var configure = spawn('./configure', [], { cwd: srcDr }); + configure.stdout.on('data', function(data) { + process.stdout.write(data.toString()); }); - proc.stderr.on("data", function(chunk) { - process.stdout.write(chunk); + configure.stderr.on('data', function(data) { + process.stderr.write(data.toString()); + }); + configure.on('close', function() { + var make = spawn('make', [], { cwd: srcDr }); + make.stdout.on('data', function(data) { + process.stdout.write(data.toString()); + }); + make.stderr.on('data', function(data) { + process.stderr.write(data.toString()); + }); + make.on('close', next); }); - - proc.on("exit", next); } }); } From 85b9250b9a56f8b7ca5a817bd97da17f640a01cc Mon Sep 17 00:00:00 2001 From: Alex Whitman Date: Sat, 17 Aug 2013 12:04:38 +0100 Subject: [PATCH 3/4] Add `-t|--temp` option to specify location for node.js sources --- bin/nexe | 11 ++++++++--- lib/index.js | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/nexe b/bin/nexe index a36dfc9..ab76723 100755 --- a/bin/nexe +++ b/bin/nexe @@ -20,6 +20,11 @@ options('r', { alias: 'runtime', default: '0.8.21', description: 'The node.js runtime to use' +}). +options('t', { + alias: 'temp', + default: '/tmp/nexe', + description: 'The path to store node.js sources' }); var argv = cli.argv; @@ -38,7 +43,7 @@ function toRelative(pt) { -require('../lib').compile({ input: toRelative(argv.i), output: toRelative(argv.o), runtime: argv.r }, function(error) { - +require('../lib').compile({ input: toRelative(argv.i), output: toRelative(argv.o), runtime: argv.r, temp: toRelative(argv.t) }, function(error) { + if(error) console.log(error.message); -}); \ No newline at end of file +}); diff --git a/lib/index.js b/lib/index.js index 7f3a6a0..cfd9e50 100644 --- a/lib/index.js +++ b/lib/index.js @@ -27,7 +27,7 @@ exports.compile = function(args, next) { */ function() { - downloadNode(args.runtime, this); + downloadNode(args.runtime, args.temp, this); }, /** @@ -93,9 +93,9 @@ exports.compile = function(args, next) { /** */ -function downloadNode(version, next) { +function downloadNode(version, temp, next) { - var tmpPath = path.join("/tmp/nexe", "node-v" + version + ".tar.gz"), + var tmpPath = path.join(temp, "node-v" + version + ".tar.gz"), srcDr = tmpPath.replace(/\.tar.gz$/, ""); try { From 7d783ced632c148ad1f38168e1f115cd554a3386 Mon Sep 17 00:00:00 2001 From: Alex Whitman Date: Sat, 17 Aug 2013 12:40:00 +0100 Subject: [PATCH 4/4] Add `temp` option to README --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a71bec4..77e5f05 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,10 @@ Or git: Usage: nexe -i [sources] -o [binary] Options: - -i, --input The entry javascript files [default: cwd] - -o, --output The output binary [default: cwd/release/app.nex] - -r, --runtime The node.js runtime to use [default: "0.8.15"] + -i, --input The entry javascript files [default: cwd] + -o, --output The output binary [default: cwd/release/app.nex] + -r, --runtime The node.js runtime to use [default: "0.8.15"] + -t, --temp The path to store node.js sources [default: /tmp/nexe] ````