Skip to content

Commit c0eb8e8

Browse files
committed
.
1 parent 06391f1 commit c0eb8e8

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

docs/scripts/generate-contributors.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
* resolve to a GitHub user are dropped — no point showing a ghost.
2424
*
2525
* Failure modes handled gracefully (all exit 0 so builds don't break):
26-
* - Not in a git repo, or no commits touch content/docs: writes an
27-
* empty `{}` and warns. The runtime component renders nothing for
28-
* pages with no entry, so the UI silently no-ops.
26+
* - Not in a git repo, or no commits touch content/docs: keeps the
27+
* previous JSON file if one exists, otherwise writes `{}`. This
28+
* matters for hosted builds that may not expose `.git` inside the
29+
* app root even though a checked-in manifest is present.
2930
* - GitHub API 403 / rate-limited: keeps existing cache entries,
3031
* skips the uncached emails, warns.
3132
*
@@ -130,6 +131,14 @@ function saveJson(path, obj) {
130131
writeFileSync(path, JSON.stringify(obj, null, 2) + '\n');
131132
}
132133

134+
function keepExistingOrWriteEmpty(path) {
135+
if (existsSync(path)) {
136+
console.warn(`[contributors] keeping existing ${path}.`);
137+
return;
138+
}
139+
saveJson(path, {});
140+
}
141+
133142
function findCommitMetaForEmail(perFile, email) {
134143
for (const byEmail of perFile.values()) {
135144
const entry = byEmail.get(email);
@@ -164,8 +173,8 @@ function isBot(author) {
164173

165174
async function main() {
166175
if (!inGitRepo()) {
167-
console.warn('[contributors] not inside a git repo; writing empty manifest.');
168-
saveJson(OUTPUT, {});
176+
console.warn('[contributors] not inside a git repo; cannot regenerate contributors manifest.');
177+
keepExistingOrWriteEmpty(OUTPUT);
169178
return;
170179
}
171180

@@ -177,7 +186,7 @@ async function main() {
177186
const files = CONTENT_DIRS.flatMap((d) => walkMdx(d));
178187
if (files.length === 0) {
179188
console.warn(`[contributors] no MDX files found under ${CONTENT_DIRS.join(', ')}.`);
180-
saveJson(OUTPUT, {});
189+
keepExistingOrWriteEmpty(OUTPUT);
181190
return;
182191
}
183192

0 commit comments

Comments
 (0)