https://github.com/sindresorhus/caller-path/issues/4Go to Github

FundedView inInteger as caller depth argument?#4

dycreated this issue 13 days ago

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,

Logs

Amount funded

$40.00

Resolve this issue and earn $36.00

Fund this issue

Fund as

Payment method

Amount(USD)

Please sign in first to fund this issue

Sign in with

Pull requests

0

    Submit

    URL of your pull request

    Submit your pull request

    Please sign in first to submit a pull request

    Sign in with