# findup

> Walk up ancester's dir up to root

Latest version **0.1.5** (published 2014-04-08) · 0 weekly downloads

## Install

```sh
npm install findup
pnpm add findup
yarn add findup
bun add findup
```

Provides the command `findup`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2014-04-08 |
| First published | 2012-04-19 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | Filirom1 |
| Maintainers | Filirom1, filirom1 |

## Links

- npm: https://www.npmjs.com/package/findup
- Repository: https://github.com/Filirom1/findup
- Issues: https://github.com/Filirom1/findup/issues
- npm.io page: https://npm.io/package/findup

## Dependencies (2)

- [colors](https://npm.io/package/colors.md) ~0.6.0-1
- [commander](https://npm.io/package/commander.md) ~2.1.0

## Recent versions

- 0.1.5 (latest) — 2014-04-08
- 0.1.4 — 2014-03-21
- 0.1.3 — 2012-11-07
- 0.1.2 — 2012-07-16
- 0.1.1 — 2012-04-20
- 0.1.0 — 2012-04-19

## README

[![build status](https://secure.travis-ci.org/Filirom1/findup.png)](http://travis-ci.org/Filirom1/findup)
Find-up
=======

### Install

    npm install -g findup

### Usage

Find up a file in ancestor's dir


    .
    ├── config.json
    └── f
        └── e
            └── d
                └── c
                    ├── b
                    │   └── a
                    └── config.json

#### Async

findup(dir, fileName, callback)
findup(dir, iterator, callback) with `iterator(dir, cb)` where cb only accept `true` or `false`

    var findup = require('findup');


    findup(__dirname + '/f/e/d/c/b/a', 'config.json', function(err, dir){
      // if(e) e === new Error('not found')
      // dir === '/f/e/d/c'
    });

or

    findup(__dirname + '/f/e/d/c/b/a', function(dir, cb){
      require('path').exists(dir + '/config.json', cb);
    }, function(err, dir){
      // if(e) e === new Error('not found')
      // dir === '/f/e/d/c'
    });


#### EventEmitter

findup(dir, fileName)

    var findup = require('findup');
    var fup = findup(__dirname + '/f/e/d/c/b/a', 'config.json');

findup(dir, iterator) with `iterator(dir, cb)` where cb only accept `true` or `false`

    var findup = require('findup');
    var fup = findup(__dirname + '/f/e/d/c/b/a', function(dir, cb){
      require('path').exists(dir + '/config.json', cb);
    });

findup return an EventEmitter. 3 events are emitted: `found`, `error`, `end`

`found` event is emitted each time a file is found.

You can stop the traversing by calling `stop` manually.

    fup.on('found', function(dir){
      // dir === '/f/e/d/c'
      fup.stop();
    });

`error` event is emitted when error happens

    fup.on('error', function(e){
      // if(e) e === new Error('not found')
    });

`end` event is emitted at the end of the traversing or after `stop()` is
called.

    fup.on('end', function(){
      // happy end
    });

#### Sync

findup(dir, fileName)
findup(dir, iteratorSync) with `iteratorSync` return `true` or `false`

    var findup = require('findup');

    try{
      var dir = findup.sync(__dirname + '/f/e/d/c/b/a', 'config.json'); // dir === '/f/e/d/c'
    }catch(e){
      // if(e) e === new Error('not found')
    }

#### CLI

    npm install -g findup

    $ cd test/fixture/f/e/d/c/b/a/
    $ findup package.json
    /root/findup/package.json

Usage

    $ findup -h

    Usage: findup [FILE]

        --name, -n       The name of the file to found
        --dir, -d        The directoy where we will start walking up    $PWD
        --help, -h       show usage                                     false
        --verbose, -v    print log                                      false

### LICENSE MIT

### Read the tests :)

---
_Source: https://npm.io/package/findup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
