/lazy-dir

Lazy define current directory

Primary LanguageTypeScriptMIT LicenseMIT

lazy-dir

Lazy define current directory

Travis CI node npm PRs


Install

$ npm install lazy-dir

Usage

const dir = require('lazy-dir')(module);

console.log(dir.here());
//=> /path/to/project/awesome

console.log(dir.here('foo', 'bar'));
//=> /path/to/project/awesome/foo/bar

API

require('lazy-dir')(module);

  • Params:
    • module: <NodeJS.Module> (required)
  • Returns: <object>

.pwd([...paths])

  • Params:
    • ...paths: <string[]> (optional)
  • Returns: <string>
  • Example:
    dir.pwd('a', 'b', 'c'); // eq: path.resolve(process.cwd(), 'a', 'b', 'c')

.here([...paths])

  • Params:
    • ...paths: <string[]> (optional)
  • Returns: <string>
  • Example:
    dir.here('a', 'b', 'c'); // eq: path.resolve(__dirname, 'a', 'b', 'c')

License

MIT © Guntur Poetra