move utils to their own file

This commit is contained in:
Craig Condon
2014-02-28 10:39:13 -08:00
parent 9caa365a3e
commit 27075a778d
6 changed files with 65 additions and 49 deletions
+1 -1
View File
@@ -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);
});
+5 -45
View File
@@ -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);
}
+3 -1
View File
@@ -1 +1,3 @@
module.exports = require("./exe");
module.exports = require("./exe");
+19
View File
@@ -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);
}
+32
View File
@@ -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);
}
+5 -2
View File
@@ -2,7 +2,7 @@
"author": "Craig Condon <craig.j.condon@gmail.com>",
"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"
}
}