[api] Fix GET /api/examples/list output (#6574)

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.
This commit is contained in:
Nathan Rajlich
2021-08-09 22:24:17 -07:00
committed by GitHub
parent 2756d1e323
commit f1009a80cd

View File

@@ -8,12 +8,13 @@ const exists = (path: string) => existsSync(path);
const isDotFile = (name: string) => name.startsWith('.');
const isDirectory = (path: string) => lstatSync(path).isDirectory();
export function summary(source: string) {
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());
.filter(d => d.isDirectory())
.map(d => d.name);
}