项目原始demo,不改动
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Ce dépôt est archivé. Vous pouvez voir les fichiers et le cloner, mais vous ne pouvez pas pousser ni ouvrir de ticket/demande d'ajout.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # find-up [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/l0cyjmvh5lq72vq2/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master)
  2. > Find a file by walking up parent directories
  3. ## Install
  4. ```
  5. $ npm install --save find-up
  6. ```
  7. ## Usage
  8. ```
  9. /
  10. └── Users
  11. └── sindresorhus
  12. ├── unicorn.png
  13. └── foo
  14. └── bar
  15. ├── baz
  16. └── example.js
  17. ```
  18. ```js
  19. // example.js
  20. const findUp = require('find-up');
  21. findUp('unicorn.png').then(filepath => {
  22. console.log(filepath);
  23. //=> '/Users/sindresorhus/unicorn.png'
  24. });
  25. findUp(['rainbow.png', 'unicorn.png']).then(filepath => {
  26. console.log(filepath);
  27. //=> '/Users/sindresorhus/unicorn.png'
  28. });
  29. ```
  30. ## API
  31. ### findUp(filename, [options])
  32. Returns a `Promise` for the filepath or `null`.
  33. ### findUp([filenameA, filenameB], [options])
  34. Returns a `Promise` for the first filepath found (by respecting the order) or `null`.
  35. ### findUp.sync(filename, [options])
  36. Returns a filepath or `null`.
  37. ### findUp.sync([filenameA, filenameB], [options])
  38. Returns the first filepath found (by respecting the order) or `null`.
  39. #### filename
  40. Type: `string`
  41. Filename of the file to find.
  42. #### options
  43. ##### cwd
  44. Type: `string`<br>
  45. Default: `process.cwd()`
  46. Directory to start from.
  47. ## Related
  48. - [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
  49. - [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
  50. - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
  51. ## License
  52. MIT © [Sindre Sorhus](https://sindresorhus.com)