(ref: string, labelForOutDir: string)
| 101 | } |
| 102 | |
| 103 | function buildRef(ref: string, labelForOutDir: string) { |
| 104 | const tmpBase = mkdtempSync(resolve(os.tmpdir(), "docs-wt-")); |
| 105 | const safeLabel = labelForOutDir.replace(/[^\w.-]+/g, "_"); |
| 106 | const worktreePath = resolve(tmpBase, safeLabel); |
| 107 | |
| 108 | run(`git worktree add --detach "${worktreePath}" "${ref}"`, { |
| 109 | cwd: currentDocsWorkspace, |
| 110 | inherit: true, |
| 111 | }); |
| 112 | |
| 113 | try { |
| 114 | const docsWorkspace = docsRelative ? resolve(worktreePath, docsRelative) : worktreePath; |
| 115 | |
| 116 | const rootPkg = existsSync(resolve(worktreePath, "package.json")); |
| 117 | const rootLock = existsSync(resolve(worktreePath, "pnpm-lock.yaml")); |
| 118 | if (rootPkg) { |
| 119 | run(`pnpm install ${rootLock ? "--frozen-lockfile" : "--no-frozen-lockfile"}`, { |
| 120 | cwd: worktreePath, |
| 121 | inherit: true, |
| 122 | }); |
| 123 | } |
| 124 | |
| 125 | const docsPkg = existsSync(resolve(docsWorkspace, "package.json")); |
| 126 | const docsLock = existsSync(resolve(docsWorkspace, "pnpm-lock.yaml")); |
| 127 | if (docsPkg && docsLock) { |
| 128 | run("pnpm install --frozen-lockfile", { cwd: docsWorkspace, inherit: true }); |
| 129 | } |
| 130 | |
| 131 | const outDir = resolve(outputDir, labelForOutDir); |
| 132 | buildDocs(docsWorkspace, outDir); |
| 133 | } finally { |
| 134 | run(`git worktree remove "${worktreePath}" --force`, { |
| 135 | cwd: currentDocsWorkspace, |
| 136 | inherit: true, |
| 137 | }); |
| 138 | rmSync(tmpBase, { recursive: true, force: true }); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | function buildBranch(branch: string, labelForOutDir: string) { |
| 143 | run(`git fetch --tags --prune origin ${branch}`, { |
no test coverage detected
searching dependent graphs…