Browse Source

Don't try to run extension loaders unless they're actually functions

v0.7.4-release
isaacs 14 years ago
committed by Ryan Dahl
parent
commit
dff1b5ad10
  1. 1
      src/node.js
  2. 1
      test/fixtures/registerExt.hello.world
  3. 2
      test/simple/test-module-loading.js

1
src/node.js

@ -251,6 +251,7 @@ var module = (function () {
this.filename = filename; this.filename = filename;
var extension = path.extname(filename) || '.js'; var extension = path.extname(filename) || '.js';
if (!extensions[extension]) extension = '.js';
extensions[extension](this, filename); extensions[extension](this, filename);
this.loaded = true; this.loaded = true;
}; };

1
test/fixtures/registerExt.hello.world

@ -0,0 +1 @@
exports.test = 'passed'

2
test/simple/test-module-loading.js

@ -76,6 +76,8 @@ require.extensions['.test'] = function (module, filename) {
}; };
assert.equal(require('../fixtures/registerExt').test, "passed"); assert.equal(require('../fixtures/registerExt').test, "passed");
// unknown extension, load as .js
assert.equal(require('../fixtures/registerExt.hello.world').test, "passed");
common.debug('load custom file types that return non-strings'); common.debug('load custom file types that return non-strings');
require.extensions['.test'] = function (module, filename) { require.extensions['.test'] = function (module, filename) {

Loading…
Cancel
Save