What I am trying to do is creating function like NodeJS require. You can do require("./your-file") and require understand that the file ./your-file is sibling of the calling module, without specifying the full path of the file.
My current problem is getting the directory of current executing function (__dirname of the executing function)
I tried things below:
- Using
module.parent.fileNamefailed when the calling method wrapped with other function. - By reading from V8 stack trace almost there but failed when run inside test runner (Jest)
It should be an easy solution for this, maybe I'm over complicate it?