Created
April 12, 2022 19:52
-
-
Save ddemydenko/3044528a150edcb9ecce67895824690d to your computer and use it in GitHub Desktop.
This file contains 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 { resolve } from 'path'; | |
import fs from 'fs/promises'; | |
async function walkIn(inputPath) { | |
const ls = await fs.readdir(inputPath, { withFileTypes: true }); | |
const files = await Promise.all(ls.map((dirent) => { | |
const res = resolve(inputPath, dirent.name); | |
return dirent.isDirectory() ? walkIn(res) : res; | |
})); | |
return [].concat(...files); | |
} | |
(async function () { | |
const res = await walkIn('../'); | |
console.log(res); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment