path-ok
v1.0.0
Published
Checks whether a filesystem path exists and is accessible.
Downloads
9
Maintainers
Readme
path-ok
URL:
https://alexstevovich.com/repos/path-ok-nodejs
Checks whether a filesystem path exists and is accessible. Returns a boolean instead of throwing. Designed to remove repetitive try/catch boilerplate when working with the Node.js filesystem.
Installation
npm install path-okExample
import pathOk from 'path-ok';
if (await pathOk('./config.json')) {
console.log('Config file exists');
}
// Works for directories as well
const hasBuildDir = await pathOk('./build');
console.log(hasBuildDir);
// → true / false
// Non-existent paths
await pathOk('./does-not-exist.txt');
// → falseLicense
Licensed under the MIT License.
