feat: 在上传文件时读取并保存 readme.md 的内容作为描述
This commit is contained in:
@@ -172,6 +172,7 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
|
|||||||
const { key, version, username } = opts || {};
|
const { key, version, username } = opts || {};
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
const data: Record<string, any> = { files: [] };
|
const data: Record<string, any> = { files: [] };
|
||||||
|
let description = '';
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const filePath = path.join(directory, file);
|
const filePath = path.join(directory, file);
|
||||||
const hash = getHash(filePath);
|
const hash = getHash(filePath);
|
||||||
@@ -180,6 +181,9 @@ const uploadFiles = async (files: string[], directory: string, opts: UploadFileO
|
|||||||
logger.error('请检查文件是否存在');
|
logger.error('请检查文件是否存在');
|
||||||
}
|
}
|
||||||
data.files.push({ path: file, hash: hash });
|
data.files.push({ path: file, hash: hash });
|
||||||
|
if(filePath.includes('readme.md')) {
|
||||||
|
description = fs.readFileSync(filePath, 'utf-8');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data.appKey = key;
|
data.appKey = key;
|
||||||
data.version = version;
|
data.version = version;
|
||||||
|
|||||||
Reference in New Issue
Block a user