require-paths-in-cwd
Like require.resolve.paths()
, but only retrieves paths inside the current working directory
Installation
npm install require-paths-in-cwd
API
const readdirClean = require('require-paths-in-cwd');
readdirClean(path)
path: string
Buffer
URL
(directory path)
Return: Promise<Array<string>>
Similar to Node.js built-in fs.readdir
, but different in the following points:
- Returns a
Promise
- Doesn't support
encoding
option - The paths are filtered with
require('junk').not
readdirClean('path/to/dir').then(paths => {
paths.includes('.Spotlight-V100'); //=> false
paths.includes('.Trashes'); //=> false
paths.includes('Desktop.ini'); //=> false
});
License
ISC License © 2017 Shinnosuke Watanabe