module: remove unnecessary property and method
`require.paths` property and `require.registerExtension` function have been throwing errors when used. They both are like this for years now. This patch removes them from the system. PR-URL: https://github.com/nodejs/node/pull/2922 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
88533881dd
commit
6ad458b752
@ -389,20 +389,10 @@ Module.prototype._compile = function(content, filename) {
|
|||||||
return Module._resolveFilename(request, self);
|
return Module._resolveFilename(request, self);
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(require, 'paths', { get: function() {
|
|
||||||
throw new Error('require.paths is removed. Use ' +
|
|
||||||
'node_modules folders, or the NODE_PATH ' +
|
|
||||||
'environment variable instead.');
|
|
||||||
}});
|
|
||||||
|
|
||||||
require.main = process.mainModule;
|
require.main = process.mainModule;
|
||||||
|
|
||||||
// Enable support to add extra extension types
|
// Enable support to add extra extension types
|
||||||
require.extensions = Module._extensions;
|
require.extensions = Module._extensions;
|
||||||
require.registerExtension = function() {
|
|
||||||
throw new Error('require.registerExtension() removed. Use ' +
|
|
||||||
'require.extensions instead.');
|
|
||||||
};
|
|
||||||
|
|
||||||
require.cache = Module._cache;
|
require.cache = Module._cache;
|
||||||
|
|
||||||
|
@ -127,10 +127,6 @@ assert.equal(require('../fixtures/registerExt2').custom, 'passed');
|
|||||||
assert.equal(require('../fixtures/foo').foo, 'ok',
|
assert.equal(require('../fixtures/foo').foo, 'ok',
|
||||||
'require module with no extension');
|
'require module with no extension');
|
||||||
|
|
||||||
assert.throws(function() {
|
|
||||||
require.paths;
|
|
||||||
}, /removed/, 'Accessing require.paths should throw.');
|
|
||||||
|
|
||||||
// Should not attempt to load a directory
|
// Should not attempt to load a directory
|
||||||
try {
|
try {
|
||||||
require('../fixtures/empty');
|
require('../fixtures/empty');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user