Skip to content
No description, website, or topics provided.
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fixtures initial commit Dec 30, 2015
.gitignore
.npmignore
.travis.yml Correct node version Mar 9, 2019
LICENSE.md chore(LICENSE.md): Add missing license file. May 20, 2018
README.md Update Readme Dec 11, 2018
appveyor.yml use yarn Mar 9, 2019
index.ts typescript Mar 9, 2019
package.json
test.ts
tsconfig.json typescript Mar 9, 2019
yarn.lock

README.md

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.
You can’t perform that action at this time.