connect-repl
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -6,4 +6,6 @@ | ||
var context; | ||
var replDisabled = !process.env.NODE_ENV || process.env.NODE_ENV == "production" | ||
var setEmptyNext = function() { | ||
@@ -15,7 +17,3 @@ context.next = function() { console.log("Nothing to continue"); }; | ||
function repl() { | ||
// always disable on production | ||
if(process.env.NODE_ENV == "production") | ||
return function connectREPLdisabled(req, res, next) { next(); }; | ||
function ensureContextExists() { | ||
if(!context) { | ||
@@ -26,2 +24,13 @@ context = require('repl').start("REPL> ").context; | ||
} | ||
} | ||
function repl() { | ||
// always disable on production | ||
if(replDisabled) | ||
return function connectREPLdisabled(req, res, next) { next(); }; | ||
ensureContextExists(); | ||
return function connectREPL(req, res, next) { | ||
@@ -50,1 +59,13 @@ if(!context) | ||
}; | ||
GLOBAL.REPL_EXPORT = repl.replExport = function replExport(name, value) { | ||
if(replDisabled) return; | ||
ensureContextExists(); | ||
console.log('REPL: Value exported to this["' + name + '"] (type ' + (typeof value) + ')'); | ||
context[name] = value; | ||
}; |
{ | ||
"name": "connect-repl", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Inject REPL as Connect or Express middleware", | ||
@@ -5,0 +5,0 @@ "keywords": ["repl", "connect", "express", "middleware", "debug", "interactive"], |
@@ -15,2 +15,7 @@ # node-connect-repl | ||
## REPL_EXPORT global function | ||
Module exports **global** function `REPL_EXPORT(name, value)` which can be called anywhere. | ||
Provided value is accesible by `name` in REPL. | ||
## Example | ||
@@ -17,0 +22,0 @@ |
3031
47
34
3