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 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. # globby
  2. > User-friendly glob matching
  3. Based on [`fast-glob`](https://github.com/mrmlnc/fast-glob) but adds a bunch of useful features.
  4. ## Features
  5. - Promise API
  6. - Multiple patterns
  7. - Negated patterns: `['foo*', '!foobar']`
  8. - Expands directories: `foo` → `foo/**/*`
  9. - Supports `.gitignore`
  10. ## Install
  11. ```
  12. $ npm install globby
  13. ```
  14. ## Usage
  15. ```
  16. ├── unicorn
  17. ├── cake
  18. └── rainbow
  19. ```
  20. ```js
  21. const globby = require('globby');
  22. (async () => {
  23. const paths = await globby(['*', '!cake']);
  24. console.log(paths);
  25. //=> ['unicorn', 'rainbow']
  26. })();
  27. ```
  28. ## API
  29. Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
  30. ### globby(patterns, options?)
  31. Returns a `Promise<string[]>` of matching paths.
  32. #### patterns
  33. Type: `string | string[]`
  34. See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).
  35. #### options
  36. Type: `object`
  37. See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones below.
  38. ##### expandDirectories
  39. Type: `boolean | string[] | object`\
  40. Default: `true`
  41. If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `object` with `files` and `extensions` like below:
  42. ```js
  43. const globby = require('globby');
  44. (async () => {
  45. const paths = await globby('images', {
  46. expandDirectories: {
  47. files: ['cat', 'unicorn', '*.jpg'],
  48. extensions: ['png']
  49. }
  50. });
  51. console.log(paths);
  52. //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
  53. })();
  54. ```
  55. Note that if you set this option to `false`, you won't get back matched directories unless you set `onlyFiles: false`.
  56. ##### gitignore
  57. Type: `boolean`\
  58. Default: `false`
  59. Respect ignore patterns in `.gitignore` files that apply to the globbed files.
  60. ### globby.sync(patterns, options?)
  61. Returns `string[]` of matching paths.
  62. ### globby.stream(patterns, options?)
  63. Returns a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams) of matching paths.
  64. Since Node.js 10, [readable streams are iterable](https://nodejs.org/api/stream.html#stream_readable_symbol_asynciterator), so you can loop over glob matches in a [`for await...of` loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) like this:
  65. ```js
  66. const globby = require('globby');
  67. (async () => {
  68. for await (const path of globby.stream('*.tmp')) {
  69. console.log(path);
  70. }
  71. })();
  72. ```
  73. ### globby.generateGlobTasks(patterns, options?)
  74. Returns an `object[]` in the format `{pattern: string, options: Object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
  75. Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
  76. ### globby.hasMagic(patterns, options?)
  77. Returns a `boolean` of whether there are any special glob characters in the `patterns`.
  78. Note that the options affect the results.
  79. This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).
  80. ### globby.gitignore(options?)
  81. Returns a `Promise<(path: string) => boolean>` indicating whether a given path is ignored via a `.gitignore` file.
  82. Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not used for the resulting filter function.
  83. ```js
  84. const {gitignore} = require('globby');
  85. (async () => {
  86. const isIgnored = await gitignore();
  87. console.log(isIgnored('some/file'));
  88. })();
  89. ```
  90. ### globby.gitignore.sync(options?)
  91. Returns a `(path: string) => boolean` indicating whether a given path is ignored via a `.gitignore` file.
  92. Takes the same options as `globby.gitignore`.
  93. ## Globbing patterns
  94. Just a quick overview.
  95. - `*` matches any number of characters, but not `/`
  96. - `?` matches a single character, but not `/`
  97. - `**` matches any number of characters, including `/`, as long as it's the only thing in a path part
  98. - `{}` allows for a comma-separated list of "or" expressions
  99. - `!` at the beginning of a pattern will negate the match
  100. [Various patterns and expected matches.](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
  101. ## globby for enterprise
  102. Available as part of the Tidelift Subscription.
  103. The maintainers of globby and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-globby?utm_source=npm-globby&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
  104. ## Related
  105. - [multimatch](https://github.com/sindresorhus/multimatch) - Match against a list instead of the filesystem
  106. - [matcher](https://github.com/sindresorhus/matcher) - Simple wildcard matching
  107. - [del](https://github.com/sindresorhus/del) - Delete files and directories
  108. - [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed