Skip to content

Get list of all directories in a given directory with TypeScript

Advertisements
  
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 do i set limits in inputs in python?

Leave a Reply

Your email address will not be published.

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