Skip to content

Instantly share code, notes, and snippets.

@nrafter
Created February 10, 2015 07:26
Show Gist options
  • Save nrafter/a9724a97a2cfe4ae7686 to your computer and use it in GitHub Desktop.
Save nrafter/a9724a97a2cfe4ae7686 to your computer and use it in GitHub Desktop.
// Given a file name, pass it to the proper extension handler.
Module.prototype.load = function(filename) {
debug('load ' + JSON.stringify(filename) +
' for module ' + JSON.stringify(this.id));
assert(!this.loaded);
this.filename = filename;
this.paths = Module._nodeModulePaths(path.dirname(filename));
var extension = path.extname(filename) || '.js';
if (!Module._extensions[extension]) extension = '.js';
Module._extensions[extension](this, filename);
this.loaded = true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment