Sha256: de7b6d277d23b5b8a3cc7d31c7a0ba19972363df2818b88573b4a29e3e89ba07

Contents?: true

Size: 1.04 KB

Versions: 80

Compression:

Stored size: 1.04 KB

Contents

# get-caller-file

[![Build Status](https://travis-ci.org/stefanpenner/get-caller-file.svg?branch=master)](https://travis-ci.org/stefanpenner/get-caller-file)
[![Build status](https://ci.appveyor.com/api/projects/status/ol2q94g1932cy14a/branch/master?svg=true)](https://ci.appveyor.com/project/embercli/get-caller-file/branch/master)

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

```bash
yarn add get-caller-file
```

## Usage

Given:

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

module.exports = function() {
  return getCallerFile(); // figures out who called it
};
```

```js
// 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.

Version data entries

80 entries across 79 versions & 14 rubygems

Version Path
appmap-0.70.1 ./node_modules/get-caller-file/README.md
appmap-0.70.0 ./node_modules/get-caller-file/README.md
appmap-0.69.0 ./node_modules/get-caller-file/README.md
appmap-0.68.2 ./node_modules/get-caller-file/README.md
appmap-0.68.1 ./node_modules/get-caller-file/README.md
disco_app-0.15.2 test/dummy/node_modules/get-caller-file/README.md
appmap-0.68.0 ./node_modules/get-caller-file/README.md
appmap-0.67.1 ./node_modules/get-caller-file/README.md
appmap-0.67.0 ./node_modules/get-caller-file/README.md
disco_app-0.18.4 test/dummy/node_modules/get-caller-file/README.md
disco_app-0.18.1 test/dummy/node_modules/get-caller-file/README.md
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/get-caller-file/README.md
disco_app-0.14.0 test/dummy/node_modules/get-caller-file/README.md
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/get-caller-file/README.md
appmap-0.66.2 ./node_modules/get-caller-file/README.md
appmap-0.66.1 ./node_modules/get-caller-file/README.md
appmap-0.66.0 ./node_modules/get-caller-file/README.md
appmap-0.65.1 ./node_modules/get-caller-file/README.md
appmap-0.65.0 ./node_modules/get-caller-file/README.md
appmap-0.64.0 ./node_modules/get-caller-file/README.md