1.0.1 • Published 6 years ago

read-all-up v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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.