diff --git a/scripts/create-zip.js b/scripts/create-zip.js index 74a5dfa..a1415c5 100644 --- a/scripts/create-zip.js +++ b/scripts/create-zip.js @@ -18,9 +18,18 @@ async function createZipWithSystemCommand(sourceDir, outputDir) { 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 zipFileName = `mp-weixin-${dateString}-${new Date().getTime()}.zip`; + const zipFileName = `mp-weixin-${dateString}-${commitId}.zip`; const zipFilePath = path.join(outputDir, zipFileName); let command;