mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 12:57:46 +00:00
A regression from #6554 caused the return value to contain a nested object with a `name` property for the `name` key of the response in the list.
21 lines
559 B
TypeScript
21 lines
559 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): string[] {
|
|
if (!exists(source) || !isDirectory(source)) {
|
|
return [];
|
|
}
|
|
|
|
return readdirSync(source, { withFileTypes: true })
|
|
.filter(d => !isDotFile(d.name))
|
|
.filter(d => d.isDirectory())
|
|
.map(d => d.name);
|
|
}
|