Skip to content

Commit c44627c

Browse files
added functionality to strip old fields
1 parent 70dc264 commit c44627c

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from "@actions/core";
22
import { CodeJSON } from "./model.js";
33
import * as helpers from "./helper.js";
4+
import { stripOutdatedFields } from "./validation.js";
45

56
const baselineCodeJSON: CodeJSON = {
67
name: "",
@@ -159,6 +160,8 @@ export async function run(): Promise<void> {
159160
};
160161
}
161162

163+
finalCodeJSON = stripOutdatedFields(finalCodeJSON)
164+
162165
core.info("Generated code.json successfully!");
163166

164167
const baseBranchName = await helpers.getBaseBranch();

src/validation.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,11 @@ export function validateCodeJSON(codeJSON: any): string[] {
127127
return `${field}: ${err.message}`;
128128
});
129129
}
130+
131+
export function stripOutdatedFields(codeJSON: any): any {
132+
try {
133+
return CodeJSONSchema.loose().parse(codeJSON)
134+
} catch (error) {
135+
return codeJSON
136+
}
137+
}

0 commit comments

Comments
 (0)