MCPcopy Index your code
hub / github.com/code-forge-io/react-router-devtools / buildRef

Function buildRef

docs/scripts/generate-docs.ts:103–140  ·  view source on GitHub ↗
(ref: string, labelForOutDir: string)

Source from the content-addressed store, hash-verified

101}
102
103function 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
142function buildBranch(branch: string, labelForOutDir: string) {
143 run(`git fetch --tags --prune origin ${branch}`, {

Callers 2

buildBranchFunction · 0.85
buildTagFunction · 0.85

Calls 2

runFunction · 0.85
buildDocsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…