Skip to content

Latest commit

 

History

History
63 lines (39 loc) · 1.16 KB

README.md

File metadata and controls

63 lines (39 loc) · 1.16 KB

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