node/deps/npm/node_modules/get-caller-file
claudiahdz db54b57042 deps: upgrade npm to 6.14.7
PR-URL: https://github.com/nodejs/node/pull/34468
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-07-26 22:30:56 -07:00
..
index.d.ts deps: upgrade npm to 6.14.7 2020-07-26 22:30:56 -07:00
index.js deps: upgrade npm to 6.14.7 2020-07-26 22:30:56 -07:00
index.js.map deps: upgrade npm to 6.14.7 2020-07-26 22:30:56 -07:00
LICENSE.md deps: upgrade npm to 6.13.7 2020-01-31 18:52:20 -08:00
package.json deps: upgrade npm to 6.14.7 2020-07-26 22:30:56 -07:00
README.md deps: upgrade npm to 6.14.7 2020-07-26 22:30:56 -07:00

get-caller-file

Build Status Build status

This is a utility, which allows a function to figure out from which file it was invoked. It does so by inspecting v8's stack trace at the time it is invoked.

Inspired by http://stackoverflow.com/questions/13227489

note: this relies on Node/V8 specific APIs, as such other runtimes may not work

Installation

yarn add get-caller-file

Usage

Given:

// ./foo.js
const getCallerFile = require('get-caller-file');

module.exports = function() {
  return getCallerFile(); // figures out who called it
};
// index.js
const foo = require('./foo');

foo() // => /full/path/to/this/file/index.js

Options:

  • getCallerFile(position = 2): where position is stack frame whos fileName we want.