Created
August 5, 2014 09:31
-
-
Save lerouxb/087b970c2da85dc30b22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = reqr = (path, m) -> | |
| before = new Date() | |
| if m | |
| ret = m.require path | |
| else | |
| ret = require path | |
| ms = new Date - before | |
| if m | |
| relative = m.filename.replace __dirname, '' | |
| p = "#{path} from .#{relative}" | |
| else | |
| if path[0] == '.' and not m | |
| console.log "module not specified for #{path}!!" | |
| p = path | |
| #console.log("require", p, "[#{ms}ms]") if ms > 100 | |
| ret | |
| # elsewhere | |
| reqr = require './reqr' | |
| thingy = reqr './thingy', module # nasty, could have added to a closure once at the top of file | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment