Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doc: add require.extensions to globals
Browse files Browse the repository at this point in the history
Closes #3028
  • Loading branch information
shama authored and bnoordhuis committed Apr 17, 2012
1 parent 7cd1690 commit 718aa50
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doc/api/globals.markdown
Expand Up @@ -61,6 +61,24 @@ but rather than loading the module, just return the resolved filename.
Modules are cached in this object when they are required. By deleting a key
value from this object, the next `require` will reload the module.

### require.extensions

* {Array}

Instruct `require` on how to handle certain file extensions.

Process files with the extension `.sjs` as `.js`:

require.extensions['.sjs'] = require.extensions['.js'];

Write your own extension handler:

require.extensions['.sjs'] = function(module, filename) {
var content = fs.readFileSync(filename, 'utf8');
// Parse the file content and give to module.exports
module.exports = content;
};

## __filename

<!-- type=var -->
Expand Down

0 comments on commit 718aa50

Please sign in to comment.