diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:50:21 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2023-10-14 15:50:21 +0800 |
| commit | 0379526e20e1ff212df23e6326741aa9c06df204 (patch) | |
| tree | 340143b0c4dc4280c88ba1591d137b53477005b3 /node_modules/doiuse/utils/getFiles.js | |
| parent | 7aba14fb7c970c6e6af82c805db2aef6d70bfe2b (diff) | |
added doiuse plugin for postcss
Diffstat (limited to 'node_modules/doiuse/utils/getFiles.js')
| -rw-r--r-- | node_modules/doiuse/utils/getFiles.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/node_modules/doiuse/utils/getFiles.js b/node_modules/doiuse/utils/getFiles.js new file mode 100644 index 00000000..3e939420 --- /dev/null +++ b/node_modules/doiuse/utils/getFiles.js @@ -0,0 +1,19 @@ +import { readdir } from 'node:fs/promises'; +import { resolve } from 'node:path'; + +/** + * recursively get all files in a directory + * @param {string} directory the directory to read + * @yields {string} the path to each file + * @return {AsyncGenerator<string>} the path to each file + */ +export async function* getFiles(directory) { + for (const entry of await readdir(directory, { withFileTypes: true })) { + const path = resolve(directory, entry.name); + if (entry.isDirectory()) { + yield* getFiles(path); + } else { + yield path; + } + } +} |
