mongoose-repl
Advanced tools
Comparing version 0.0.2 to 0.0.3
// Generated by CoffeeScript 1.6.3 | ||
var CoffeeScript, magic_cb, mongoose, node_repl, util, vm, writer, _, | ||
var CoffeeScript, format_error, inspect, magic_cb, mongoose, node_repl, util, vm, writer, _, | ||
__slice = [].slice; | ||
@@ -25,3 +25,3 @@ | ||
writer = function(val) { | ||
inspect = function(val) { | ||
var _ref; | ||
@@ -35,2 +35,16 @@ val = (_ref = val != null ? typeof val.toObject === "function" ? val.toObject() : void 0 : void 0) != null ? _ref : val; | ||
writer = function(val) { | ||
if (_.isArray(val)) { | ||
return "[" + (_.map(val, inspect).join(',\n')) + "]"; | ||
} else { | ||
return inspect(val); | ||
} | ||
}; | ||
format_error = function(err) { | ||
var name; | ||
name = err.name === 'SyntaxError' ? 'Syntax Error' : err.name; | ||
return "" + name + ": " + err.message; | ||
}; | ||
magic_cb = function(context) { | ||
@@ -66,10 +80,10 @@ return function() { | ||
cmd = cmd.replace(/^\(([\s\S]*)\n\)$/m, '$1'); | ||
js = CoffeeScript.compile(cmd, { | ||
bare: true | ||
}); | ||
try { | ||
js = CoffeeScript.compile(cmd, { | ||
bare: true | ||
}); | ||
res = vm.runInContext(js, context, filename); | ||
} catch (_error) { | ||
err = _error; | ||
return cb(err); | ||
return cb(format_error(err)); | ||
} | ||
@@ -93,2 +107,8 @@ if (res instanceof mongoose.Query) { | ||
conn: conn, | ||
ObjectId: conn.base.Types.ObjectId, | ||
inspect: function() { | ||
var val; | ||
val = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | ||
return console.log(_.map(val, inspect).join(', ')); | ||
}, | ||
magic: magic_cb(repl.context) | ||
@@ -95,0 +115,0 @@ }); |
{ | ||
"name": "mongoose-repl", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A Mongo REPL with the full power of Mongoose", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
13986
190