Sunday, 11 June 2017

node.js know the file of where the require happened

I have 2 files

// file1.js
//some js code that will do what I ask in the question
module.exports = myFunc

//file2.js
require('./file1')

Is it possible, in any kind of way, for file1.js to know who required it? so when file2 requires file1, file1 will know that it was file2?



via Nick Ginanto

No comments:

Post a Comment