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.
npm install --save path-__dirname
yarn add path-__dirname
// ES2015
import dirname from 'path-__dirname'
// CommonJS
var dirname = require('path-__dirname')
Get a path in the dirname.
- path {String} (optional) path to get in the dirname
Returns a string.
import dirname from 'path-__dirname'
dirname() === __dirname //=> true
dirname('pineapple') //=> C:/User/Spongebob Squarepants/projects/bikini-bottom/pineapple
All pull requests and issues welcome!
If you're not sure how, check out the great video tutorials on egghead.io!
MIT © Sam Gluck