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
clapton-0.0.26 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.25 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.24 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.23 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.22 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.21 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.20 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.19 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.18 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.17 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.16 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.15 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.14 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.13 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.12 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.11 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.10 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.9 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.8 lib/clapton/javascripts/node_modules/get-caller-file/README.md
clapton-0.0.7 lib/clapton/javascripts/node_modules/get-caller-file/README.md