sindresorhus/caller-path




The issue has been solved
Integer as caller depth argument? #4
dy posted onGitHub
Hi @sindresorhus!
Awesome package, I am using it in save-file and in upcoming audio release.
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 saveAs
path:
//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')
What I do now is use callsites directly here:
var callerPath = callsites()[1].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,
Fund this Issue
Rewarded pull request
Add `depth` option #6submitted byyaodingyd(558)
Click to copy link
Recent activities