mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
20 lines
527 B
TypeScript
20 lines
527 B
TypeScript
/**
|
|
* Get example list from extracted folder
|
|
*/
|
|
|
|
import { lstatSync, existsSync, readdirSync } from 'fs';
|
|
|
|
const exists = (path: string) => existsSync(path);
|
|
const isDotFile = (name: string) => name.startsWith('.');
|
|
const isDirectory = (path: string) => lstatSync(path).isDirectory();
|
|
|
|
export function summary(source: string) {
|
|
if (!exists(source) || !isDirectory(source)) {
|
|
return [];
|
|
}
|
|
|
|
return readdirSync(source, { withFileTypes: true })
|
|
.filter(d => !isDotFile(d.name))
|
|
.filter(d => d.isDirectory());
|
|
}
|