Preserve repo Face identity metadata
This commit is contained in:
parent
b7aeda1bbf
commit
80f3a4ccc1
1 changed files with 13 additions and 0 deletions
|
|
@ -174,10 +174,12 @@ async function writeRepoFaceIdentity(
|
|||
repoPath: string,
|
||||
identityPath: string,
|
||||
): Promise<void> {
|
||||
const existing = await readExistingIdentity(identityPath);
|
||||
await writeFile(
|
||||
identityPath,
|
||||
`${JSON.stringify(
|
||||
{
|
||||
...existing,
|
||||
schemaVersion: "voidbot.repo_face_identity.v0",
|
||||
identityId: identity.id,
|
||||
repoName: identity.repoName,
|
||||
|
|
@ -194,6 +196,17 @@ async function writeRepoFaceIdentity(
|
|||
);
|
||||
}
|
||||
|
||||
async function readExistingIdentity(identityPath: string): Promise<Record<string, unknown>> {
|
||||
try {
|
||||
const parsed = JSON.parse(stripLeadingBom(await readFile(identityPath, "utf8"))) as unknown;
|
||||
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
||||
? parsed as Record<string, unknown>
|
||||
: {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
async function writeReadmeIfMissing(path: string, content: string): Promise<void> {
|
||||
if (existsSync(path)) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue