Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module: remove unnecessary property and method #2922

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,10 @@ Module.prototype._compile = function(content, filename) {
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;

// Enable support to add extra extension types
require.extensions = Module._extensions;
require.registerExtension = function() {
throw new Error('require.registerExtension() removed. Use ' +
'require.extensions instead.');
};

require.cache = Module._cache;

Expand Down
4 changes: 0 additions & 4 deletions test/sequential/test-module-loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ assert.equal(require('../fixtures/registerExt2').custom, 'passed');
assert.equal(require('../fixtures/foo').foo, 'ok',
'require module with no extension');

assert.throws(function() {
require.paths;
}, /removed/, 'Accessing require.paths should throw.');

// Should not attempt to load a directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can you add a test to confirm that require.paths returns undefined or whatever the expected value is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Probably good to do the same for require.registerExtension().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Trott Do we really need that? There will be no reference to that in code, but there will be a test which will check if paths is undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is this PR changes the behavior of the code and there ought to be a test for that change. So a test that the property has, in fact, been successfully removed seems appropriate. But if you think it's overkill, I'm OK without it. (I'll edit my comments above to indicate they are nits.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Trott Hmmm, whenever we remove something from the system we don't add tests to make sure that they are really removed, right? So, I feel that it is not necessary. Let's see what others feel.

try {
require('../fixtures/empty');
Expand Down