e2e-promotion-spec-imports.mjs 584 B

1234567891011121314
  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.replace(
  7. /(?:\.\.\/){3,}(?=(?:helpers|pages|bots|fixtures)\/)/gu,
  8. (prefix) => prefix.slice(6),
  9. );
  10. if (rewritten !== original) {
  11. writeFileSync(specPath, rewritten, "utf8");
  12. }
  13. }