@@ -17,19 +17,19 @@ require(pathToBootstrap);
17
17
const fileLogService = $injector . resolve < IFileLogService > ( FileLogService , { logFile } ) ;
18
18
fileLogService . logData ( { message : "Initializing Cleanup process." } ) ;
19
19
20
- const actionsToExecute : ICleanupAction [ ] = [ ] ;
20
+ const commandsInfos : ISpawnCommandInfo [ ] = [ ] ;
21
21
const filesToDelete : string [ ] = [ ] ;
22
22
23
23
const executeCleanup = async ( ) => {
24
24
const $childProcess = $injector . resolve < IChildProcess > ( "childProcess" ) ;
25
- for ( const action of actionsToExecute ) {
25
+ for ( const commandInfo of commandsInfos ) {
26
26
try {
27
- fileLogService . logData ( { message : `Start executing action : ${ JSON . stringify ( action ) } ` } ) ;
27
+ fileLogService . logData ( { message : `Start executing command : ${ JSON . stringify ( commandInfo ) } ` } ) ;
28
28
29
- await $childProcess . trySpawnFromCloseEvent ( action . command , action . args , { } , { throwError : true , timeout : action . timeout || 3000 } ) ;
30
- fileLogService . logData ( { message : `Successfully executed action : ${ JSON . stringify ( action ) } ` } ) ;
29
+ await $childProcess . trySpawnFromCloseEvent ( commandInfo . command , commandInfo . args , { } , { throwError : true , timeout : commandInfo . timeout || 3000 } ) ;
30
+ fileLogService . logData ( { message : `Successfully executed command : ${ JSON . stringify ( commandInfo ) } ` } ) ;
31
31
} catch ( err ) {
32
- fileLogService . logData ( { message : `Unable to execute action : ${ JSON . stringify ( action ) } ` , type : FileLogMessageType . Error } ) ;
32
+ fileLogService . logData ( { message : `Unable to execute command : ${ JSON . stringify ( commandInfo ) } ` , type : FileLogMessageType . Error } ) ;
33
33
}
34
34
}
35
35
@@ -42,21 +42,21 @@ const executeCleanup = async () => {
42
42
process . exit ( ) ;
43
43
} ;
44
44
45
- const addCleanupAction = ( newAction : ICleanupAction ) : void => {
46
- if ( _ . some ( actionsToExecute , currentAction => _ . isEqual ( currentAction , newAction ) ) ) {
47
- fileLogService . logData ( { message : `cleanup-process will not add action for execution as it has been added already: ${ JSON . stringify ( newAction ) } ` } ) ;
45
+ const addCleanupAction = ( commandInfo : ISpawnCommandInfo ) : void => {
46
+ if ( _ . some ( commandsInfos , currentCommandInfo => _ . isEqual ( currentCommandInfo , commandInfo ) ) ) {
47
+ fileLogService . logData ( { message : `cleanup-process will not add command for execution as it has been added already: ${ JSON . stringify ( commandInfo ) } ` } ) ;
48
48
} else {
49
- fileLogService . logData ( { message : `cleanup-process added action for execution: ${ JSON . stringify ( newAction ) } ` } ) ;
50
- actionsToExecute . push ( newAction ) ;
49
+ fileLogService . logData ( { message : `cleanup-process added command for execution: ${ JSON . stringify ( commandInfo ) } ` } ) ;
50
+ commandsInfos . push ( commandInfo ) ;
51
51
}
52
52
} ;
53
53
54
- const removeCleanupAction = ( actionToRemove : ICleanupAction ) : void => {
55
- if ( _ . some ( actionsToExecute , currentAction => _ . isEqual ( currentAction , actionToRemove ) ) ) {
56
- _ . remove ( actionsToExecute , currentAction => _ . isEqual ( currentAction , actionToRemove ) ) ;
57
- fileLogService . logData ( { message : `cleanup-process removed action for execution: ${ JSON . stringify ( actionToRemove ) } ` } ) ;
54
+ const removeCleanupAction = ( commandInfo : ISpawnCommandInfo ) : void => {
55
+ if ( _ . some ( commandsInfos , currentCommandInfo => _ . isEqual ( currentCommandInfo , commandInfo ) ) ) {
56
+ _ . remove ( commandsInfos , currentCommandInfo => _ . isEqual ( currentCommandInfo , commandInfo ) ) ;
57
+ fileLogService . logData ( { message : `cleanup-process removed command for execution: ${ JSON . stringify ( commandInfo ) } ` } ) ;
58
58
} else {
59
- fileLogService . logData ( { message : `cleanup-process cannot remove action for execution as it has note been added before: ${ JSON . stringify ( actionToRemove ) } ` } ) ;
59
+ fileLogService . logData ( { message : `cleanup-process cannot remove command for execution as it has note been added before: ${ JSON . stringify ( commandInfo ) } ` } ) ;
60
60
}
61
61
} ;
62
62
@@ -82,24 +82,24 @@ const removeDeleteAction = (filePath: string): void => {
82
82
}
83
83
} ;
84
84
85
- process . on ( "message" , async ( cleanupProcessMessage : ICleanupProcessMessage ) => {
85
+ process . on ( "message" , async ( cleanupProcessMessage : ICleanupMessageBase ) => {
86
86
fileLogService . logData ( { message : `cleanup-process received message of type: ${ JSON . stringify ( cleanupProcessMessage ) } ` } ) ;
87
87
88
- switch ( cleanupProcessMessage . actionType ) {
89
- case CleanupProcessMessageType . AddCleanAction :
90
- addCleanupAction ( ( < ICleanupActionMessage > cleanupProcessMessage ) . action ) ;
88
+ switch ( cleanupProcessMessage . messageType ) {
89
+ case CleanupProcessMessage . AddCleanCommand :
90
+ addCleanupAction ( ( < ISpawnCommandCleanupMessage > cleanupProcessMessage ) . commandInfo ) ;
91
91
break ;
92
- case CleanupProcessMessageType . RemoveCleanAction :
93
- removeCleanupAction ( ( < ICleanupActionMessage > cleanupProcessMessage ) . action ) ;
92
+ case CleanupProcessMessage . RemoveCleanCommand :
93
+ removeCleanupAction ( ( < ISpawnCommandCleanupMessage > cleanupProcessMessage ) . commandInfo ) ;
94
94
break ;
95
- case CleanupProcessMessageType . AddDeleteAction :
96
- addDeleteAction ( ( < ICleanupDeleteActionMessage > cleanupProcessMessage ) . filePath ) ;
95
+ case CleanupProcessMessage . AddDeleteFileAction :
96
+ addDeleteAction ( ( < IDeleteFileCleanupMessage > cleanupProcessMessage ) . filePath ) ;
97
97
break ;
98
- case CleanupProcessMessageType . RemoveDeleteAction :
99
- removeDeleteAction ( ( < ICleanupDeleteActionMessage > cleanupProcessMessage ) . filePath ) ;
98
+ case CleanupProcessMessage . RemoveDeleteFileAction :
99
+ removeDeleteAction ( ( < IDeleteFileCleanupMessage > cleanupProcessMessage ) . filePath ) ;
100
100
break ;
101
101
default :
102
- fileLogService . logData ( { message : `Unable to handle message of type ${ cleanupProcessMessage . actionType } . Full message is ${ JSON . stringify ( cleanupProcessMessage ) } ` , type : FileLogMessageType . Error } ) ;
102
+ fileLogService . logData ( { message : `Unable to handle message of type ${ cleanupProcessMessage . messageType } . Full message is ${ JSON . stringify ( cleanupProcessMessage ) } ` , type : FileLogMessageType . Error } ) ;
103
103
break ;
104
104
}
105
105
0 commit comments