Skip to content

Instantly share code, notes, and snippets.

@lerouxb
Created August 5, 2014 09:31
Show Gist options
  • Select an option

  • Save lerouxb/087b970c2da85dc30b22 to your computer and use it in GitHub Desktop.

Select an option

Save lerouxb/087b970c2da85dc30b22 to your computer and use it in GitHub Desktop.
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