Get the callsite of the caller function
$ npm install --save caller-callsite
// foo.js const callerCallsite = require('caller-callsite'); module.exports = () => { console.log(callerCallsite().getFileName()); //=> '/Users/sindresorhus/dev/unicorn/bar.js' }
// bar.js const foo = require('./foo'); foo();
Returns a callsite
object.
MIT © Sindre Sorhus