mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 17:13:10 +00:00

PR-URL: https://github.com/nodejs/node/pull/6132 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: thefourtheye <thechargingvolcano@gmail.com>
19 lines
466 B
JavaScript
19 lines
466 B
JavaScript
'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;
|
|
};
|