Here is some sample code from three files:
// foo.js
var myFunc = require(./myFunc);
function foo(){
myFunc(message);
}
// bar.js
var myFunc = require(./myFunc);
function bar(){
myFunc(message);
}
// myFunc.js
module.exports = myFunc;
function myFunc(arg1){
console.log(arg1);
// Here I need the file path of the caller function
// For example, /path/to/foo.js and /path/to/bar.js
}
I need to get the file path of the caller function dynamically, without any extra argument passing, for myFunc
.