mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
466 B
19 lines
466 B
9 years ago
|
'use strict';
|
||
|
var path = require('path');
|
||
|
var resolveFrom = require('resolve-from');
|
||
|
var callerPath = require('caller-path');
|
||
|
|
||
|
module.exports = function (moduleId) {
|
||
|
if (typeof moduleId !== 'string') {
|
||
|
throw new TypeError('Expected a string');
|
||
|
}
|
||
|
|
||
|
var filePath = resolveFrom(path.dirname(callerPath()), moduleId);
|
||
|
var tmp = require.cache[filePath];
|
||
|
delete require.cache[filePath];
|
||
|
var ret = require(filePath);
|
||
|
require.cache[filePath] = tmp;
|
||
|
|
||
|
return ret;
|
||
|
};
|