Skip to content

Instantly share code, notes, and snippets.

@ddemydenko
Created April 12, 2022 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddemydenko/3044528a150edcb9ecce67895824690d to your computer and use it in GitHub Desktop.
Save ddemydenko/3044528a150edcb9ecce67895824690d to your computer and use it in GitHub Desktop.
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