e2e-promotion-spec-imports.mjs 677 B

123456789101112131415
  1. import { readFileSync, writeFileSync } from "node:fs";
  2. export function rewriteFormalSpecImports(specPath) {
  3. const original = readFileSync(specPath, "utf8");
  4. // Bug 根因:pending spec 比 formal spec 多两层目录,只重写 helpers/pages 会让
  5. // case-local 文件 fixture 在转正后漂移到 packages/desktop/fixtures 并于运行时 ENOENT。
  6. const rewritten = original
  7. .replaceAll("../../../helpers/", "../helpers/")
  8. .replaceAll("../../../pages/", "../pages/")
  9. .replaceAll("../../../bots/", "../bots/")
  10. .replaceAll("../../../fixtures/", "../fixtures/");
  11. if (rewritten !== original) {
  12. writeFileSync(specPath, rewritten, "utf8");
  13. }
  14. }