Skip to content

Commit

Permalink
Update implode script
Browse files Browse the repository at this point in the history
  • Loading branch information
bibixx committed Jul 4, 2024
1 parent 66ae76d commit 6a5df18
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scripts/implodeOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ async function processSubject(subjectId: string) {
}

const fileContents = await file.json();
delete fileContents.createdAt;
delete fileContents.$schema;

outData.data.push(fileContents);
}
Expand All @@ -67,6 +65,18 @@ async function processSubject(subjectId: string) {
const schemaPath = relative(overridesPath, schemaAbsolutePath);
outData.$schema = schemaPath;

let updatedAt = outData.updatedAt;
for (const data of outData.data) {
const createdAt = data.createdAt;

delete data.createdAt;
delete data.$schema;

updatedAt = Math.max(data.updatedAt ?? 0, createdAt ?? 0);
}

outData.updatedAt = updatedAt;

const outFile = Bun.file(join(overridesPath, `${subjectId}.json`));
await Bun.write(outFile, stringify(outData));
}
Expand Down

0 comments on commit 6a5df18

Please sign in to comment.