Skip to content

Commit 98c05a1

Browse files
mbgnavntoft
andauthored
Fix argument validation in rollback-changelog.ts
Co-authored-by: Mads Navntoft <navntoft@github.com>
1 parent 74b15aa commit 98c05a1

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

pr-checks/rollback-changelog.ts

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,16 @@ export function updateChangelog(
5050

5151
function main() {
5252
try {
53-
const { values } = parseArgs({
54-
options: {
55-
"target-version": {
56-
type: "string",
57-
short: "t",
58-
},
59-
"rollback-version": {
60-
type: "string",
61-
short: "r",
62-
},
63-
"new-version": {
64-
type: "string",
65-
short: "n",
66-
},
67-
},
68-
strict: true,
69-
});
53+
const options = {
54+
"target-version": { type: "string", short: "t" },
55+
"rollback-version": { type: "string", short: "r" },
56+
"new-version": { type: "string", short: "n" },
57+
} as const;
7058

71-
for (const [key, val] of Object.entries(values)) {
59+
const { values } = parseArgs({ options, strict: true });
60+
61+
for (const key of Object.keys(options)) {
62+
const val = values[key as keyof typeof values];
7263
if (val === undefined || val.trim() === "") {
7364
throw new Error(`Argument '--${key}' is required.`);
7465
}

0 commit comments

Comments
 (0)