0.1.6 • Published 2 years ago
@giancarl021/locate v0.1.6
locate
Locate a file based on root of project or cwd
Installation
npm:
npm install --save @giancarl021/locate
yarn:
yarn add @giancarl021/locate
Usage
From root:
const locate = require('@giancarl021/locate');
const databasePath = locate('data/database');
// Will return <root>/data/database, independent of the file who calls it
From CWD:
const locate = require('@giancarl021/locate');
const package = locate('package.json', true);
// Will return <process.cwd()>/package.json, independent of the file who calls it