Created
August 29, 2019 02:37
-
-
Save decadef20/af0f3ea2945f92a2cd354dc3b93ab844 to your computer and use it in GitHub Desktop.
nodejs read directories
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
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