Skip to content

Instantly share code, notes, and snippets.

@mschultheiss83
Forked from capaj/module_parent_bar.js
Last active August 29, 2015 14:20
Show Gist options
  • Save mschultheiss83/b3564602d413f4d04049 to your computer and use it in GitHub Desktop.
Save mschultheiss83/b3564602d413f4d04049 to your computer and use it in GitHub Desktop.
var myFunc = require("./myFunc");
(function bar(){
myFunc("bar message");
})();
var myFunc = require("./myFunc");
(function foo(){
myFunc("foo message");
})();
function myFunc(arg){
console.log(arg);
console.log(module.parent.filename);
// Here I need the file path of the caller function
// For example, "/path/to/foo.js" and "/path/to/bar.js"
}
module.exports = myFunc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment