File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ export abstract class CodacyCli {
3838 public abstract analyze ( options : { file ?: string ; tool ?: string } ) : Promise < ProcessedSarifResult [ ] | null >
3939
4040 public abstract configDiscover ( filePath : string ) : Promise < void >
41+
42+ public abstract configReset ( ) : Promise < void >
4143
4244 public getCliCommand ( ) : string {
4345 return this . _cliCommand
Original file line number Diff line number Diff line change @@ -276,4 +276,16 @@ export class MacCodacyCli extends CodacyCli {
276276 }
277277 }
278278 }
279+
280+ public async configReset ( ) : Promise < void > {
281+ const resetCommand = `${ this . getCliCommand ( ) } config reset`
282+ const resetParams = this . getIdentificationParameters ( )
283+
284+ const hasIdentificationParams = await this . validateIdentificationParameters ( resetParams )
285+ if ( ! hasIdentificationParams ) {
286+ Logger . debug ( 'CLI mode is remote and no identification parameters provided. Skipping update and config reset.' )
287+ return
288+ }
289+ await this . execAsync ( resetCommand , resetParams )
290+ }
279291}
Original file line number Diff line number Diff line change @@ -35,4 +35,8 @@ export class WinCodacyCli extends CodacyCli {
3535 public configDiscover ( _filePath : string ) : Promise < void > {
3636 throw new Error ( NOT_SUPPORTED )
3737 }
38+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
39+ public configReset ( ) : Promise < void > {
40+ throw new Error ( NOT_SUPPORTED )
41+ }
3842}
Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ export class Cli {
8383
8484 // set Cli command if found
8585 await this . cliInstance . preflightCodacyCli ( false )
86+
87+ // check for an already installed CLI to update tools config
88+ await this . cliInstance . configReset ( )
8689
8790 return this . cliInstance
8891 }
You can’t perform that action at this time.
0 commit comments