diff --git a/bin/nexe b/bin/nexe index 6230898..8f9f7ac 100755 --- a/bin/nexe +++ b/bin/nexe @@ -55,7 +55,7 @@ require('../lib').compile({ input : toRelative(argv.i), output : toRelative(argv.o), nodeVersion : argv.r, - temp : toRelative(argv.t) }, function(error) { + nodeTempDir : toRelative(argv.t) }, function(error) { if(error) console.log(error.message); }); diff --git a/lib/exe.js b/lib/exe.js index 98c1d07..f26d762 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -11,6 +11,10 @@ glob = require("glob"), sardines = require("sardines"), spawn = child_process.spawn; + +var _log = require("./log"), +_monkeypatch = require("./monkeypatch"); + /** */ @@ -25,7 +29,7 @@ exports.compile = function (options, complete) { */ function downloadNode (next) { - _downloadNode(options.nodeVersion, "/tmp/nexe", next); + _downloadNode(options.nodeVersion, options.nodeTempDir, next); }, /** @@ -252,33 +256,6 @@ function _monkeyPatchMainJs (compiler, complete) { ); } -/** - */ - -function _monkeypatch (filePath, monkeyPatched, processor, complete) { - - async.waterfall([ - - function read (next) { - fs.readFile(filePath, "utf8", next); - }, - - // TODO - need to parse gyp file - this is a bit hacker - function monkeypatch (content, next) { - - if (monkeyPatched(content)) return complete(); - - _log("monkey patch %s", filePath); - processor(content, next); - }, - - function write (content, next) { - fs.writeFile(filePath, content, "utf8", next); - } - ], complete); -} - - /** */ @@ -316,20 +293,3 @@ function _logProgress (req) { return req; } -/** - */ - -function _log () { - - var args = Array.prototype.slice.call(arguments, 0), - level = args.shift(); - - if (!~["log", "error", "warn"].indexOf(level)) { - args.unshift(level); - level = "log"; - } - - args[0] = "----> " + args[0]; - - console[level].apply(console, args); -} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index ba6760c..d7c212c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1 +1,3 @@ -module.exports = require("./exe"); \ No newline at end of file +module.exports = require("./exe"); + + diff --git a/lib/log.js b/lib/log.js new file mode 100644 index 0000000..a162c30 --- /dev/null +++ b/lib/log.js @@ -0,0 +1,19 @@ +module.exports = _log; + +/** + */ + +function _log () { + + var args = Array.prototype.slice.call(arguments, 0), + level = args.shift(); + + if (!~["log", "error", "warn"].indexOf(level)) { + args.unshift(level); + level = "log"; + } + + args[0] = "----> " + args[0]; + + console[level].apply(console, args); +} \ No newline at end of file diff --git a/lib/monkeypatch.js b/lib/monkeypatch.js new file mode 100644 index 0000000..0e78562 --- /dev/null +++ b/lib/monkeypatch.js @@ -0,0 +1,32 @@ +var async = require("async"), +fs = require("fs"); + +module.exports = _monkeypatch; + + +/** + */ + + +function _monkeypatch (filePath, monkeyPatched, processor, complete) { + + async.waterfall([ + + function read (next) { + fs.readFile(filePath, "utf8", next); + }, + + // TODO - need to parse gyp file - this is a bit hacker + function monkeypatch (content, next) { + + if (monkeyPatched(content)) return complete(); + + _log("monkey patch %s", filePath); + processor(content, next); + }, + + function write (content, next) { + fs.writeFile(filePath, content, "utf8", next); + } + ], complete); +} \ No newline at end of file diff --git a/package.json b/package.json index 3f6c268..88a4843 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Craig Condon ", "name": "nexe", "description": "Roll node.s applications into a single executable", - "version": "0.2.4", + "version": "0.2.5", "repository": { "type": "git", "url": "git://github.com/crcn/nexe.git" @@ -25,5 +25,8 @@ "bin": { "nexe": "./bin/nexe" }, - "devDependencies": {} + "devDependencies": { + "expect.js": "~0.3.1", + "mocha": "~1.17.1" + } }