Files
MorphDoc/scripts/clean-docx-gate-output.mjs
T
SkyJourneyandClaude Sonnet 5 7533226366 chore: 规范化 DOCX 发布门禁产出目录并新增清理脚本
问题修复:verify-docx-release-gate-suite.mjs 默认输出目录此前写死为
output/docx-release-gate-v0.6.2,版本升级后需要手工改字符串。改为从根
package.json 动态读取版本号,生成 output/docx-release-gate/v<version>/,
环境变量 MD_TO_PDF_RELEASE_GATE_OUTPUT_DIR 覆盖行为不变。

新增能力:新增 npm run clean:docx-gate-output,清理新目录结构及历史遗留的
output/docx-release-gate-v* 旧命名目录。

验证结果:test:docx-release-gate-suites、test:docx-real-world-corpus 通过;
本机手工构造新旧两种命名目录验证清理脚本均能正确删除且不误删其他 output
子目录。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K5N6pcbjV4jVfXrcH3NcLP
2026-08-26 20:05:00 +08:00

29 lines
896 B
JavaScript

import fs from "node:fs";
import path from "node:path";
const repositoryDirectory = path.resolve(import.meta.dirname, "..");
const outputDirectory = path.join(repositoryDirectory, "output");
const targets = [path.join(outputDirectory, "docx-release-gate")];
if (fs.existsSync(outputDirectory)) {
for (const entry of fs.readdirSync(outputDirectory, { withFileTypes: true })) {
if (entry.isDirectory() && /^docx-release-gate-v/u.test(entry.name)) {
targets.push(path.join(outputDirectory, entry.name));
}
}
}
let removedCount = 0;
for (const target of targets) {
if (fs.existsSync(target)) {
fs.rmSync(target, { recursive: true, force: true });
process.stdout.write(`已删除:${path.relative(repositoryDirectory, target)}\n`);
removedCount += 1;
}
}
if (removedCount === 0) {
process.stdout.write("没有找到需要清理的门禁产出目录。\n");
}