Created
October 28, 2020 19:45
-
-
Save azmenak/5c69d2a9b4d194a8fd3fbd6ba0dd7cb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path' | |
import fs from 'fs' | |
function* getFilesRecursive(dir) { | |
const dirents = fs.readdirSync(dir, { withFileTypes: true }); | |
for (const dirent of dirents) { | |
const res = path.resolve(dir, dirent.name); | |
if (dirent.isDirectory()) { | |
yield* getFiles(res); | |
} else { | |
yield res; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment