We have been stalled on ESLint 3.8.0 for some time. Current ESLint is 3.13.0. We have been unable to upgrade because of more aggressive reporting on some rules, including indentation. ESLint configuration options and bugfixes are now such that we can reasonably upgrade. PR-URL: https://github.com/nodejs/node/pull/10561 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
29 lines
754 B
JavaScript
29 lines
754 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);
|
|
|
|
// delete itself from module parent
|
|
if (require.cache[filePath] && require.cache[filePath].parent) {
|
|
var i = require.cache[filePath].parent.children.length;
|
|
|
|
while (i--) {
|
|
if (require.cache[filePath].parent.children[i].id === filePath) {
|
|
require.cache[filePath].parent.children.splice(i, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
// delete module from cache
|
|
delete require.cache[filePath];
|
|
|
|
// return fresh module
|
|
return require(filePath);
|
|
};
|