# caller-dir

> A tool which could get the dirpath of a function method`s caller

Latest version **1.0.4** (published 2018-12-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install caller-dir
pnpm add caller-dir
yarn add caller-dir
bun add caller-dir
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2018-12-29 |
| First published | 2018-12-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alex |
| Maintainers | bonjs |
| Keywords | caller, dir |

## Links

- npm: https://www.npmjs.com/package/caller-dir
- npm.io page: https://npm.io/package/caller-dir

## Recent versions

- 1.0.4 (latest) — 2018-12-29
- 1.0.3 — 2018-12-29
- 1.0.2 — 2018-12-26
- 1.0.1 — 2018-12-26
- 1.0.0 — 2018-12-26

## README

# caller-dir [![Build Status](https://travis-ci.org/bonjs/caller-dir.svg?branch=master)](https://travis-ci.org/bonjs/caller-dir) [![](https://img.shields.io/npm/v/caller-dir.svg)](https://www.npmjs.com/package/caller-dir) [![](https://img.shields.io/npm/l/caller-dir.svg)](https://img.shields.io/npm/l/caller-dir.svg)

### A tool which could get the dirpath of a function method's caller

~~~bash
npm install caller-dir
~~~

Usually, if you want to get the current path, you can use `__dirname` in Nodejs, if you want to get the caller's dirpath, you can call the function with a parameter which is `__dirname`, but is not graceful.

Now you can use this little tool `caller-dir` to get the caller's dirpath gracefully.


eg.
file A `/src/module/a.js`
~~~javascript
const getCallerDir = require('caller-dir');

function A() {
	console.log(getCallerDir());
}
module.exports = A;
~~~

file B `/src/b.js`
~~~javascript
var A = require('./module/a');
A();
~~~

output: `/src`

---
_Source: https://npm.io/package/caller-dir · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
