Skip to content

Get list of all directories in a given directory with TypeScript

import * as fs from "fs"
import * as path from "path"
function getDirectories(directory: string): string[] {
    return fs.readdirSync(directory).filter(file => fs.statSync(path.join(directory, file)).isDirectory())
See also  TypeScript code snippet - How to see all commits in git?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.