diff options
author | Kyle Robinson Young <kyle@dontkry.com> | 2012-04-17 09:15:51 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-04-17 19:10:42 +0400 |
commit | 718aa505c47eecf0ef2c28ec3a7c1f5d63a9d6d6 (patch) | |
tree | 4d16dbdc472bef7bb8213d25befcaa379cc86983 /doc | |
parent | 7cd1690f3dab62fea1c06ab26ade985cb1c85740 (diff) |
doc: add require.extensions to globals
Closes #3028
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/globals.markdown | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 5df0b9e5591..d8fb257e7a4 100644 --- a/doc/api/globals.markdown +++ b/doc/api/globals.markdown @@ -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 --> |