Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5559947

Browse files
author
abrulic
committed
fix?
1 parent7017599 commit5559947

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

‎docs/scripts/generate-docs.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{typeExecSyncOptions,execSync}from"node:child_process";
22
import{cpSync,existsSync,mkdirSync,mkdtempSync,rmSync,writeFileSync}from"node:fs";
33
importosfrom"node:os";
4-
import{join,resolve,posixaspathPosix}from"node:path";
4+
importpath,{join,resolve,posixaspathPosix}from"node:path";
55
import{parseArgs}from"node:util";
66
importchalkfrom"chalk";
77
importsemverfrom"semver";
@@ -41,8 +41,7 @@ try {
4141
}
4242

4343
constrepoPath=(...segs:string[])=>
44-
pathPosix.join(...segs.filter(Boolean).map(s=>s.replace(/^\/+|\/+$/g,"")));
45-
44+
path.normalize(path.join(...segs.filter(Boolean)));
4645

4746
constallTags=()=>run("git tag --list").split("\n").filter(Boolean);
4847

@@ -70,13 +69,14 @@ function hasLocalRef(ref: string) {
7069
try{run(`git show-ref --verify --quiet${ref}`);returntrue;}catch{returnfalse;}
7170
}
7271

72+
constREPO_ROOT=run("git rev-parse --show-toplevel",{cwd:currentDocsWorkspace});
73+
7374
functionrefHasPath(ref:string,pathFromRepoRoot:string):boolean{
75+
constp=pathFromRepoRoot.replace(/^\/+/,"").replace(/\/+$/,"");
7476
try{
75-
constout=run(`git ls-tree -r --name-only${ref} -- "${pathFromRepoRoot}"`);
76-
returnout.trim().length>0;
77-
}catch{
78-
returnfalse;
79-
}
77+
run(`git -C "${REPO_ROOT}" rev-parse --verify --quiet "${ref}:${p}"`);
78+
returntrue;
79+
}catch{returnfalse;}
8080
}
8181

8282
functionbuildDocs(sourceDir:string,outDir:string){
@@ -211,11 +211,11 @@ function isPullRequestCI() {
211211
builtVersions=[...tags];
212212
}else{
213213
// Fallback: build default branch (useful if you want a "main" channel)
214-
constcheckPath=repoPath(docsRelative,contentDir);// e.g. "docs/content"
215-
run(`git fetch --prune origin${defaultBranch}`,{cwd:currentDocsWorkspace,inherit:true});
216-
consthasOnDefault=refHasPath(`origin/${defaultBranch}`,checkPath);
214+
constcheckPath=repoPath(docsRelative,contentDir);// "docs/content"
215+
run(`git fetch --prune origin${defaultBranch}`,{cwd:currentDocsWorkspace,inherit:true});
217216

218-
if(!hasOnDefault){
217+
consthasOnDefault=refHasPath(`origin/${defaultBranch}`,checkPath);
218+
if(!hasOnDefault){
219219
thrownewError(`Default branch 'origin/${defaultBranch}' has no '${checkPath}'. Pass --versions to build tags.`);
220220
}
221221
console.log(chalk.cyan(`(ci) Building docs from '${defaultBranch}' →${defaultBranch}`));
@@ -237,4 +237,4 @@ export const versions = ${JSON.stringify(builtVersions, null, 2)} as const
237237
})().catch((e)=>{
238238
console.error(chalk.red("❌ Build failed:"),e);
239239
process.exit(1);
240-
});
240+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp