feat(scripts): ZIP文件名使用Git提交ID替换时间戳
This commit is contained in:
@@ -18,9 +18,18 @@ async function createZipWithSystemCommand(sourceDir, outputDir) {
|
|||||||
throw new Error(`源目录不存在: ${sourceDir}`);
|
throw new Error(`源目录不存在: ${sourceDir}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成文件名
|
// 获取当前 Git 提交 ID(短 hash)
|
||||||
|
let commitId = 'unknown';
|
||||||
|
try {
|
||||||
|
const { stdout } = await execAsync('git rev-parse --short HEAD', { cwd: path.join(__dirname, '..') });
|
||||||
|
commitId = stdout.trim();
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('无法获取 Git 提交 ID,使用 unknown 代替');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成文件名:mp-weixin-<日期>-<提交ID>.zip
|
||||||
const dateString = new Date().toISOString().split('T')[0];
|
const dateString = new Date().toISOString().split('T')[0];
|
||||||
const zipFileName = `mp-weixin-${dateString}-${new Date().getTime()}.zip`;
|
const zipFileName = `mp-weixin-${dateString}-${commitId}.zip`;
|
||||||
const zipFilePath = path.join(outputDir, zipFileName);
|
const zipFilePath = path.join(outputDir, zipFileName);
|
||||||
|
|
||||||
let command;
|
let command;
|
||||||
|
|||||||
Reference in New Issue
Block a user