requirefresh
Advanced tools
Comparing version 1.0.1 to 1.1.1
@@ -5,3 +5,3 @@ // Generated by CoffeeScript 1.6.3 | ||
app = { | ||
requireFresh: function(path, next) { | ||
requireFreshSafe: function(path, next) { | ||
var d, result; | ||
@@ -17,6 +17,3 @@ result = null; | ||
try { | ||
path = require('path').resolve(path); | ||
delete require.cache[path]; | ||
result = require(path); | ||
return delete require.cache[path]; | ||
return result = app.requireFresh(path); | ||
} catch (_error) { | ||
@@ -27,8 +24,14 @@ err = _error; | ||
} finally { | ||
if (typeof next === "function") { | ||
next(null, result); | ||
} | ||
return typeof next === "function" ? next(null, result) : void 0; | ||
} | ||
}); | ||
return result; | ||
}, | ||
requireFresh: function(path) { | ||
var result; | ||
path = require('path').resolve(path); | ||
delete require.cache[path]; | ||
result = require(path); | ||
delete require.cache[path]; | ||
return result; | ||
} | ||
@@ -35,0 +38,0 @@ }; |
{ | ||
"name": "requirefresh", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "Require a file without adding it into the require cache", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/bevry/requirefresh", |
@@ -23,3 +23,9 @@ # Require Fresh | ||
``` javascript | ||
var theLoadedModule = require('requirefresh').requireFresh('my-module-path') | ||
// Via call and return with no error handling | ||
var result = require('requirefresh').requireFresh('my-module-path') | ||
// Via callback uses domains for errors (with try/catch for node 0.8 support) | ||
var resultOrError = require('requireFresh').requireFreshSafe('my-module-path', function(err,result){ | ||
}); | ||
``` | ||
@@ -26,0 +32,0 @@ |
5029
35
42