Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # find-up [![Build Status](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up)
  2. > Find a file or directory by walking up parent directories
  3. ## Install
  4. ```
  5. $ npm install 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. `example.js`
  19. ```js
  20. const path = require('path');
  21. const findUp = require('find-up');
  22. (async () => {
  23. console.log(await findUp('unicorn.png'));
  24. //=> '/Users/sindresorhus/unicorn.png'
  25. console.log(await findUp(['rainbow.png', 'unicorn.png']));
  26. //=> '/Users/sindresorhus/unicorn.png'
  27. console.log(await findUp(async directory => {
  28. const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
  29. return hasUnicorns && directory;
  30. }, {type: 'directory'}));
  31. //=> '/Users/sindresorhus'
  32. })();
  33. ```
  34. ## API
  35. ### findUp(name, options?)
  36. ### findUp(matcher, options?)
  37. Returns a `Promise` for either the path or `undefined` if it couldn't be found.
  38. ### findUp([...name], options?)
  39. Returns a `Promise` for either the first path found (by respecting the order of the array) or `undefined` if none could be found.
  40. ### findUp.sync(name, options?)
  41. ### findUp.sync(matcher, options?)
  42. Returns a path or `undefined` if it couldn't be found.
  43. ### findUp.sync([...name], options?)
  44. Returns the first path found (by respecting the order of the array) or `undefined` if none could be found.
  45. #### name
  46. Type: `string`
  47. Name of the file or directory to find.
  48. #### matcher
  49. Type: `Function`
  50. A function that will be called with each directory until it returns a `string` with the path, which stops the search, or the root directory has been reached and nothing was found. Useful if you want to match files with certain patterns, set of permissions, or other advanced use-cases.
  51. When using async mode, the `matcher` may optionally be an async or promise-returning function that returns the path.
  52. #### options
  53. Type: `object`
  54. ##### cwd
  55. Type: `string`<br>
  56. Default: `process.cwd()`
  57. Directory to start from.
  58. ##### type
  59. Type: `string`<br>
  60. Default: `'file'`<br>
  61. Values: `'file'` `'directory'`
  62. The type of paths that can match.
  63. ##### allowSymlinks
  64. Type: `boolean`<br>
  65. Default: `true`
  66. Allow symbolic links to match if they point to the chosen path type.
  67. ### findUp.exists(path)
  68. Returns a `Promise<boolean>` of whether the path exists.
  69. ### findUp.sync.exists(path)
  70. Returns a `boolean` of whether the path exists.
  71. #### path
  72. Type: `string`
  73. Path to a file or directory.
  74. ### findUp.stop
  75. A [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) that can be returned by a `matcher` function to stop the search and cause `findUp` to immediately return `undefined`. Useful as a performance optimization in case the current working directory is deeply nested in the filesystem.
  76. ```js
  77. const path = require('path');
  78. const findUp = require('find-up');
  79. (async () => {
  80. await findUp(directory => {
  81. return path.basename(directory) === 'work' ? findUp.stop : 'logo.png';
  82. });
  83. })();
  84. ```
  85. ## Related
  86. - [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
  87. - [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
  88. - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
  89. - [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module like `require.resolve()` but from a given path
  90. ---
  91. <div align="center">
  92. <b>
  93. <a href="https://tidelift.com/subscription/pkg/npm-find-up?utm_source=npm-find-up&utm_medium=referral&utm_campaign=readme">Get professional support for 'find-up' with a Tidelift subscription</a>
  94. </b>
  95. <br>
  96. <sub>
  97. Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
  98. </sub>
  99. </div>