feat: 在上传文件时读取并保存 readme.md 的内容作为描述

This commit is contained in:
2025-12-17 11:22:36 +08:00
parent 48f2695367
commit 0ca5989a40

View File

@@ -172,6 +172,7 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
const { key, version, username } = opts || {};
const form = new FormData();
const data: Record<string, any> = { files: [] };
let description = '';
for (const file of files) {
const filePath = path.join(directory, file);
const hash = getHash(filePath);
@@ -180,6 +181,9 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
logger.error('请检查文件是否存在');
}
data.files.push({ path: file, hash: hash });
if(filePath.includes('readme.md')) {
description = fs.readFileSync(filePath, 'utf-8');
}
}
data.appKey = key;
data.version = version;