findup

WebJar for findup

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

findup
Последняя версия

Последняя версия

0.1.5
Дата

Дата

Тип

Тип

jar
Описание

Описание

findup
WebJar for findup
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/Filirom1/findup

Скачать findup

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/findup/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>findup</artifactId>
    <version>0.1.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/findup/
implementation 'org.webjars.npm:findup:0.1.5'
// https://jarcasting.com/artifacts/org.webjars.npm/findup/
implementation ("org.webjars.npm:findup:0.1.5")
'org.webjars.npm:findup:jar:0.1.5'
<dependency org="org.webjars.npm" name="findup" rev="0.1.5">
  <artifact name="findup" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='findup', version='0.1.5')
)
libraryDependencies += "org.webjars.npm" % "findup" % "0.1.5"
[org.webjars.npm/findup "0.1.5"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm : colors jar [0.6.0-1,0.7)
org.webjars.npm : commander jar [2.1.0,2.2)

Модули Проекта

Данный проект не имеет модулей.

build status 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

Options

  • maxdepth: (Number, default -1) How far to traverse before giving up. If maxdepth is -1, then there is no limit.

Async

findup(dir, fileName, options, callback) findup(dir, iterator, options, 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, options)

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

findup(dir, iterator, options) 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 :)

Версии библиотеки

Версия
0.1.5