path-__dirname

2.1.0 • Public • Published

path-__dirname

Get a path in the __dirname

Note: this will not work for modules that are executed indirectly, for example testing engines like Jest.

Unlike the resolve-* these modules allow resolution of non-module paths.

Install

npm install --save path-__dirname
yarn add path-__dirname

Import

// ES2015
import dirname from 'path-__dirname'
// CommonJS
var dirname = require('path-__dirname')

Usage

dirname([path]) : String

Get a path in the dirname.

  • path {String} (optional) path to get in the dirname

Returns a string.

Example

import dirname from 'path-__dirname'
 
dirname() === __dirname //=> true
dirname('pineapple') //=> C:/User/Spongebob Squarepants/projects/bikini-bottom/pineapple

See also

Contributing

All pull requests and issues welcome!

If you're not sure how, check out the great video tutorials on egghead.io!

License

MIT © Sam Gluck

Package Sidebar

Install

npm i path-__dirname

Weekly Downloads

3

Version

2.1.0

License

MIT

Last publish

Collaborators

  • sdgluck