import { readdir } from 'fs/promises'

/**
 * Gets the directories under the specified source directory
 * @param {string} source path to the parent directory
 * @returns {Promise<string[]>} the names of the child directories
 */
export const getChildDirectories = async source => 
  (await readdir(source, { withFileTypes: true }))
    .filter(dirent => dirent.isDirectory())
    .map(dirent => dirent.name)