Skip to content

Instantly share code, notes, and snippets.

@robwozniak
Created June 23, 2020 16:15
Show Gist options
  • Save robwozniak/3d266902ac7efe9d7d03f3caa22ee4db to your computer and use it in GitHub Desktop.
Save robwozniak/3d266902ac7efe9d7d03f3caa22ee4db to your computer and use it in GitHub Desktop.
const fs = require('fs')
const path = require('path')
const getAllFiles = dir => fs.readdirSync(dir).reduce((files, file) => {
const name = path.join(dir, file)
const isDirectory = fs.statSync(name).isDirectory()
return isDirectory ? [...files, ...getAllFiles(name)] : [...files, name]
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment