Code Monkey home page Code Monkey logo

vfile-find-up's Introduction

vfile-find-up Build Status Coverage Status

Find vfiles by searching the file system upwards.

Installation

npm:

npm install vfile-find-up

Usage

var findUp = require('vfile-find-up');

// Search for files named `package.json` from the current
// working directory upwards:
findUp.all('package.json', console.log);
// null [ VFile {
//     data: {},
//     messages: [],
//     history: [ '/Users/tilde/projects/oss/vfile-find-up/package.json' ],
//     cwd: '/Users/tilde/projects/oss/vfile-find-up' } ]

API

vfileFindUp.all(tests[, path], callback)

Search for tests upwards. Invokes callback with either an error or an array of files passing tests. Note: Virtual Files are not read (their contents is not populated).

Parameters
  • tests (string|Function|Array.<tests>) — A test is a function invoked with a vfile. If an array is passed in, any test must match a given file for it to be included. If a string is passed in, the basename or extname of files must match it for them to be included.
  • path (string, default: process.cwd()) — Place to searching from;
  • callback (function cb(err[, files])); — Function invoked with all matching files.

vfileFindUp.one(tests[, path], callback)

Like vfileFindUp.all, but invokes callback with the first found file, or null.

function test(file)

Check whether a virtual file should be included. Invoked with a vfile.

Returns
  • true or vfileFindUp.INCLUDE — Include the file in the results;
  • vfileFindUp.BREAK — Stop searching for files;
  • anything else is ignored: the file is not included.

The different flags can be combined by using the pipe operator: vfileFindUp.INCLUDE | vfileFindUp.BREAK.

License

MIT © Titus Wormer

vfile-find-up's People

Contributors

greenkeeperio-bot avatar wooorm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.