@elricb/find-file-up

Steps up directories until file is found.


Keywords
directory, search, up
License
MIT
Install
npm install @elricb/find-file-up@2.0.1

Documentation

@elricb/find-file-up

Steps up one directory at a time searching for a file. Stops at user home directory or top of path tree. I made this to help with the dotenv package; see dotenv Usage for usage.

Requirements

  • node - recommended lts version >= 12

Install

$ npm install --save @elricb/find-file-up

Usage

import process from "process";
import path from "path";
import findFileUp from "@elricb/find-file-up";

const configPath = findFileUp(__dirname, ".env") || path.join(process.env.HOME, ".env");

console.log(configPath);

dotenv Usage

import findFileUp from "@elricb/find-file-up";

require("dotenv").config({ path: findFileUp(__dirname, ".env") || undefined });

Documentation

Release Notes

View commit tag for release notes.

API

See ./docs/index.html.