read-all-up

Read all matching files or directories by walking up parent directories


Keywords
read, all, find, up, findup, readup, find-up, read-up, look-up, look, file, search, match, package, resolve, parent, parents, folder, directory, dir, walk, walking, path, recursive
License
MIT
Install
npm install read-all-up@1.0.1

Documentation

read-all-up

Read all matching files or directories by walking up parent directories

Install

yarn add read-all-up

Example

const readAllUp = require('read-all-up');

readAllUp('package.json', files => {
  console.log(files);
  // [{
  //   filePath: '/nested/current-dir/package.json',
  //   fileContents: Buffer | string,
  // }, {
  //   filePath: '/nested/package.json',
  //   fileContents: Buffer | string,
  // }, {
  //   filePath: '/package.json',
  //   fileContents: Buffer | string,
  // }]
});

API

readAllUp(filename | filename[], [options])

Returns a Promise for the files.

readAllUp.sync(filename | filename[], [options])

Returns files.

filename

Type: string

Filename of the file to find.

options

cwd

Type: string Default: process.cwd()

Directory to start from.

encoding

Type: string

Encoding to read the files as.