Change returned data type
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Rebecca-Chou 2022-02-02 17:06:13 +08:00
parent 6e8f7bba94
commit fbcdec33eb
1 changed files with 26 additions and 8 deletions

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { readFile, readdir, access } from "fs/promises";
import path from "path";
@ -11,18 +12,17 @@ const EXECS_PATH = path.join("content", "team", "execs");
const fileType = ".md";
const { year, term } = getCurrentTerm();
export interface execMembers {
name: string;
order: string;
}
export interface Metadata {
name: string;
role: string;
image: string;
}
// export async function getExecNames() {
// return (await readdir(EXECS_PATH))
// .filter((name) => name.endsWith(fileType))
// .map((name) => name.slice(0, -1 * fileType.length));
// }
export async function getExecNames() {
if (process.env.USE_LDAP?.toLowerCase() !== "true") {
return (await readdir(EXECS_PATH))
@ -44,12 +44,30 @@ export async function getExecNames() {
)}${year})(exec=True))`,
});
const execMembers = searchEntries.map((item) => item.cn as string);
let execMembers: execMembers[] = [];
execMembers = searchEntries
.map((item) => {
return {
name: item.cn as string,
order: item.order as string,
};
})
.sort((item1: execMembers, item2: execMembers) =>
item1.order.localeCompare(item2.order)
);
const formattedExec: string[] = execMembers.map(
(member) =>
`0${member.order}-
${member.name.split(" ")[1].toLowerCase()}-
${member.name.split(" ")[0].toLowerCase()}`
);
} finally {
await client.unbind();
}
return execMembers;
return formattedExec;
}
export async function getExec(fileName: string, convert = true) {