Skip to content

Commit a98f33d

Browse files
committed
Add a safety cap to protect against unexpected failure
1 parent b7a8800 commit a98f33d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ export async function run(): Promise<void> {
1919

2020
if (usersNotInGoogle.size > 0) {
2121
console.log(`Users not in google: ${Array.from(usersNotInGoogle).join(', ')}`)
22-
if (config.removeUsers) await removeUsersFromGitHubOrg(usersNotInGoogle)
22+
23+
if (config.removeUsers) {
24+
if (usersNotInGithub.size <= config.maxRemoveUsers) {
25+
await removeUsersFromGitHubOrg(usersNotInGoogle)
26+
} else {
27+
console.log(`Not removing users because there are too many`)
28+
}
29+
}
2330
}
2431

2532
const exitCode = usersNotInGoogle.size > 0 || usersNotInGithub.size > 0 ? config.exitCodeOnMissmatch : 0

src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ export const config = {
55
get removeUsers(): boolean {
66
return process.env.REMOVE_USERS?.toLowerCase() === 'true'
77
},
8+
get maxRemoveUsers(): number{
9+
return parseInt(process.env.MAX_REMOVE_USERS ?? '0' ) || 100
10+
},
811
get exitCodeOnMissmatch(): number {
912
return parseInt(process.env.EXIT_CODE_ON_MISMATCH ?? '0') || 0
1013
},

0 commit comments

Comments
 (0)