Unfortunately it turns out that oftentimes we need not the caller path, but caller's caller path.
For example, I expect path to be the invocator's path, not the
//test/index.js const saveAs = require('save-file') //so I expect the file to be placed into `test` directory //but caller-path inside `saveAs` returns `saveAs` path `.../node_modules/save-file/index.js` saveAs(buf, 'my-record.wav')
var callerPath = callsites().getFileName()
What I'd suggest is passing an
id of the caller for that purpose:
var cpath = callerPath(1)
That would not break the current behaviour and at the same time would allow to specify caller. If you need a PR I can come up with one.
Thank you for your time, sincerely,