find-down

2018-10-13 admin

find-down是什么

什么是find-down,Find a file by walking down parent directories.

find-down使用教程帮助文档

find-down Build status for find-down on Circle CI.

Find a file by walking down parent directories.

Why?

  • Find files high up in the filesystem quickly.
  • Good at finding things that are probably in $HOME.
  • Is to find-up what indexOf is to lastIndexOf.

Install

npm install find-down --save

Usage

Get it into your program.

const findDown = require('find-down');

Find the topmost file with the given name.

findDown('unicorn.png').then((filepath) => {
    console.log(filepath);  // => '/Users/sholladay/unicorn.png'
});

API

findDown(filename, option)

Returns a Promise for either the filepath or null if it cannot be found.

findDown([filenameA, filenameB], option)

Returns a Promise for either the first filepath found (by respecting the order) or null if none could be found.

filename

Type: string

Filename of the file to find.

option

cwd

Type: string Default: process.cwd()

Directory to end with.

Contributing

See our contributing guidelines for more details.

  1. Fork it.
  2. Make a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

License

MPL-2.0 © Seth Holladay

Go make something, dang it.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-42563.html

文章标题:find-down

回到顶部