README.md 490 Bytes

caller

Figure out your caller (thanks to @substack).

Initialization Time Caller
// foo.js

var bar = require('bar');
// bar.js

var caller = require('caller');
console.log(caller()); // `/path/to/foo.js`
Runtime Caller
// foo.js

var bar = require('bar');
bar.doWork();
// bar.js

var caller = require('caller');

exports.doWork = function () {
    console.log(caller());  // `/path/to/foo.js`
};