Fixes #99, resolves #97 by warning on missing file. New examples. New log functions

This commit is contained in:
RainbowDashDC
2015-02-15 11:05:24 -08:00
parent 06d7730802
commit b040337a94
17 changed files with 111 additions and 15 deletions
+14 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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);
}
}