dirname.js
ES6 __dirname
utility.
This is an ES module that exposes a function that returns the equivalent of the commonjs global __dirname
variable.
Install
npm install --save-dev @bzelip/dirname
API
Usage
dirname(importMetaUrl)
Returns absolute path of file.
Example:
import dirname from '@bzelip/__dirname';
const __dirname = dirname(import.meta.url);
Option
<importMetaUrl>
URL object, as returned from import.meta.url
;
Author
Brian Zelip, https://zelip.me
References
- David Herron (2018). Implementing __dirname in ES6 modules using import.meta.url
LICENSE
MIT