perf: async read file (#4978)

* perf: async read file

* package

* doc
This commit is contained in:
Archer
2025-06-08 18:46:36 +08:00
committed by GitHub
parent 188008255d
commit 7494ce8453
9 changed files with 36 additions and 32 deletions

View File

@@ -14,11 +14,11 @@ const getTemplateNameList = () => {
);
const templatesPath = path.join(path.dirname(filePath), 'src');
return fs.readdirSync(templatesPath) as string[];
return fs.promises.readdir(templatesPath);
};
const getFileTemplates = async (): Promise<AppTemplateSchemaType[]> => {
const templateNames = getTemplateNameList();
const templateNames = await getTemplateNameList();
return Promise.all(
templateNames.map<Promise<AppTemplateSchemaType>>(async (name) => {