File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,17 +12,27 @@ export async function run(): Promise<void> {
1212 const usersNotInGithub = new Set ( Array . from ( googleUsers ) . filter ( ( x ) => ! gitHubUsers . has ( x ) ) )
1313
1414 const usersNotInGoogle = new Set ( Array . from ( gitHubUsers ) . filter ( ( x ) => ! googleUsers . has ( x ) ) )
15+ let unfixedMismatch = false
16+
1517 if ( usersNotInGithub . size > 0 ) {
1618 console . log ( `Users not in github: ${ Array . from ( usersNotInGithub ) . join ( ', ' ) } ` )
17- if ( config . addUsers ) await addUsersToGitHubOrg ( usersNotInGithub )
19+ if ( config . addUsers ) {
20+ await addUsersToGitHubOrg ( usersNotInGithub )
21+ } else {
22+ unfixedMismatch = true
23+ }
1824 }
1925
2026 if ( usersNotInGoogle . size > 0 ) {
2127 console . log ( `Users not in google: ${ Array . from ( usersNotInGoogle ) . join ( ', ' ) } ` )
22- if ( config . removeUsers ) await removeUsersFromGitHubOrg ( usersNotInGoogle )
28+ if ( config . removeUsers ) {
29+ await removeUsersFromGitHubOrg ( usersNotInGoogle )
30+ } else {
31+ unfixedMismatch = true
32+ }
2333 }
2434
25- const exitCode = usersNotInGoogle . size > 0 || usersNotInGithub . size > 0 ? config . exitCodeOnMissmatch : 0
35+ const exitCode = unfixedMismatch ? config . exitCodeOnMissmatch : 0
2636
2737 process . exit ( exitCode )
2838}
Original file line number Diff line number Diff line change @@ -30,8 +30,24 @@ describe('missmatch', () => {
3030 await mod . run ( )
3131 return expect ( processExitSpy ) . toBeCalledWith ( 0 )
3232 } )
33- it ( 'should exit with 122 if defined when there is a missmatch' , async ( ) => {
33+ it ( 'should exit with 122 if defined when there is an unfixed missmatch' , async ( ) => {
3434 process . env . EXIT_CODE_ON_MISMATCH = '122'
35+ delete process . env . ADD_USERS
36+ delete process . env . REMOVE_USERS
37+ await mod . run ( )
38+ return expect ( processExitSpy ) . toBeCalledWith ( 122 )
39+ } )
40+ it ( 'should exit with 0 when mismatch is fixed by adding users' , async ( ) => {
41+ process . env . EXIT_CODE_ON_MISMATCH = '122'
42+ process . env . ADD_USERS = 'true'
43+ process . env . REMOVE_USERS = 'true'
44+ await mod . run ( )
45+ return expect ( processExitSpy ) . toBeCalledWith ( 0 )
46+ } )
47+ it ( 'should exit with 122 when only add is enabled but remove mismatch exists' , async ( ) => {
48+ process . env . EXIT_CODE_ON_MISMATCH = '122'
49+ process . env . ADD_USERS = 'true'
50+ delete process . env . REMOVE_USERS
3551 await mod . run ( )
3652 return expect ( processExitSpy ) . toBeCalledWith ( 122 )
3753 } )
You can’t perform that action at this time.
0 commit comments