mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
* add eslint-plugin-import and configure import sorting rules * apply `eslint . --fix` * disable import order rule for test files * enable import order rule for test files and disable it inline after mock imports * prettier * address failed tests by removing unused i18n mocks from test files * reorder import statement for createApp to address failed test * Remove disable/enable blocks * Resolve conflict with VSCode organize imports functionality (#26461) * Update to use default grouping and prevent adding newlines in between Co-authored-by: ian <licitdev@gmail.com> * apply eslint fix * run prettier --------- Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com> Co-authored-by: ian <licitdev@gmail.com>
33 lines
674 B
TypeScript
33 lines
674 B
TypeScript
import path from 'path';
|
|
import fse from 'fs-extra';
|
|
|
|
interface ListFoldersOptions {
|
|
/**
|
|
* Ignore folders starting with a period `.`
|
|
*/
|
|
ignoreHidden?: boolean;
|
|
}
|
|
|
|
export async function listFolders(location: string, options?: ListFoldersOptions): Promise<string[]> {
|
|
const fullPath = path.resolve(location);
|
|
const files = await fse.readdir(fullPath);
|
|
|
|
const directories: string[] = [];
|
|
|
|
for (const file of files) {
|
|
if (options?.ignoreHidden && file.startsWith('.')) {
|
|
continue;
|
|
}
|
|
|
|
const filePath = path.join(fullPath, file);
|
|
|
|
const stats = await fse.stat(filePath);
|
|
|
|
if (stats.isDirectory()) {
|
|
directories.push(file);
|
|
}
|
|
}
|
|
|
|
return directories;
|
|
}
|