Skip to content

Instantly share code, notes, and snippets.

@decadef20
Created August 29, 2019 02:37
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 decadef20/af0f3ea2945f92a2cd354dc3b93ab844 to your computer and use it in GitHub Desktop.
Save decadef20/af0f3ea2945f92a2cd354dc3b93ab844 to your computer and use it in GitHub Desktop.
nodejs read directories
const { lstatSync, readdirSync } = require('fs')
const { join } = require('path')
const isDirectory = source => lstatSync(source).isDirectory()
const getDirectories = source =>
readdirSync(source).map(name => join(source, name)).filter(isDirectory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment