This commit is contained in:
+14
-6
@@ -1,15 +1,16 @@
|
||||
var mdeps = require("module-deps"),
|
||||
through = require("through"),
|
||||
async = require("async"),
|
||||
//uglify = require("uglify-js"),
|
||||
builtins = require("builtins");
|
||||
|
||||
var _log = require("./log");
|
||||
|
||||
function bundle (input, complete) {
|
||||
|
||||
async.waterfall([
|
||||
|
||||
/**
|
||||
* first we resolve all of the deps
|
||||
*/
|
||||
|
||||
function resolveDeps (next) {
|
||||
@@ -39,9 +40,9 @@ function bundle (input, complete) {
|
||||
function end() {
|
||||
var content = buffer.join("");
|
||||
// console.log(content);
|
||||
|
||||
|
||||
/*var source = uglify.parse(content, {
|
||||
/*
|
||||
// TODO add uglify flag
|
||||
var source = uglify.parse(content, {
|
||||
strict: false
|
||||
});
|
||||
source.figure_out_scope();
|
||||
@@ -63,8 +64,15 @@ function bundle (input, complete) {
|
||||
if (id == 'nexeres') { return false; } //treat our new moudle as a builtin module
|
||||
return !~builtins.indexOf(id);
|
||||
},
|
||||
extensions: ['.js', '.json' ]
|
||||
extensions: ['.js', '.json' ],
|
||||
ignoreMissing: true
|
||||
});
|
||||
|
||||
/** event for missing packages, fixes conditional requires **/
|
||||
md.on('missing', function(id, parent) {
|
||||
_log("warn", "couldn't find require '"+id+"', errors may occur.");
|
||||
});
|
||||
|
||||
md.pipe(through(function (chunk) {
|
||||
deps.push(chunk);
|
||||
}, function () {
|
||||
@@ -82,7 +90,7 @@ function bundle (input, complete) {
|
||||
for (var i = deps.length; i--;) {
|
||||
var dep = deps[i];
|
||||
|
||||
var req = "function (require, module, exports, __dirname) { \n"
|
||||
var req = "function (require, module, exports, __dirname) { \n"
|
||||
if (dep.id.toLowerCase().indexOf(".json", dep.id.length - 5) !== -1) {
|
||||
//this is the result of require("someFile.json"), so we need to export it from the function
|
||||
req += "module.exports = "
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ exports.compile = function (options, complete) {
|
||||
/*
|
||||
* Have we been given a custom flag for python executable?
|
||||
*/
|
||||
if(options.python!=='python' && options.python!=="") {
|
||||
if(options.python!=='python' && options.python!=="" && options.python!==undefined) {
|
||||
if(isWin) {
|
||||
isPy=options.python.replace(/\//gm, "\\"); // use windows file paths, batch is sensitive.
|
||||
} else {
|
||||
@@ -150,7 +150,7 @@ exports.compile = function (options, complete) {
|
||||
_log("cp %s %s", nodeCompiler.releasePath, options.output);
|
||||
ncp(nodeCompiler.releasePath, options.output, function (err) {
|
||||
if (err) {
|
||||
console.log("* NOTICE * Failed to copy binary. Did the build fail?");
|
||||
_log("error", "Couldn't copy binary.");
|
||||
throw err; // dump raw error object
|
||||
}
|
||||
_log('copied');
|
||||
|
||||
+11
-2
@@ -1,10 +1,13 @@
|
||||
module.exports = _log;
|
||||
|
||||
/**
|
||||
* logging aka stdout wrapper
|
||||
*/
|
||||
|
||||
function _log () {
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
level = args.shift();
|
||||
|
||||
@@ -13,7 +16,13 @@ function _log () {
|
||||
level = "log";
|
||||
}
|
||||
|
||||
args[0] = "----> " + args[0];
|
||||
if(level == "log") {
|
||||
args[0] = "----> " + args[0];
|
||||
} else if(level == "error") {
|
||||
args[0] = "....> " + colors.red("ERROR: ") + args[0]
|
||||
} else if(level == "warn") {
|
||||
args[0] = "....> " + colors.yellow("WARNING: ") + args[0]
|
||||
}
|
||||
|
||||
console[level].apply(console, args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user