Skip to content

Instantly share code, notes, and snippets.

@miyaoka
Created July 26, 2021 09:57
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 miyaoka/32588131da0264e3699a4fa2e2c5f9d6 to your computer and use it in GitHub Desktop.
Save miyaoka/32588131da0264e3699a4fa2e2c5f9d6 to your computer and use it in GitHub Desktop.
const getFilePathList = (dir: string): string[] => {
return fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
const path = `${dir}/${entry.name}`
return entry.isDirectory() ? getFilePathList(path) : path
})
}
const files = getFilePathList(targetPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment