File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export class CxWrapper {
1717 private static semaphore = new Semaphore ( 1 ) ; // Semaphore with 1 slot
1818 config : CxConfig ;
1919 cxInstaller : CxInstaller ;
20- constructor ( cxScanConfig : CxConfig , logFilePath ?: string ) {
20+ private constructor ( cxScanConfig : CxConfig , logFilePath ?: string ) {
2121 this . cxInstaller = new CxInstaller ( process . platform ) ;
2222 this . config = new CxConfig ( ) ;
2323 getLoggerWithFilePath ( logFilePath )
@@ -62,6 +62,10 @@ export class CxWrapper {
6262 async init ( ) : Promise < void > {
6363 return await this . cxInstaller . downloadIfNotInstalledCLI ( ) ;
6464 }
65+
66+ public cloneWithNewConfig ( scanConfig : CxConfig ) : CxWrapper {
67+ return new CxWrapper ( scanConfig ) ;
68+ }
6569
6670 initializeCommands ( formatRequired : boolean ) : string [ ] {
6771 this . config . pathToExecutable = this . cxInstaller . getExecutablePath ( ) ;
Original file line number Diff line number Diff line change @@ -4,11 +4,9 @@ import {CxConfig} from "./CxConfig";
44class CxWrapperFactory {
55 static async createWrapper ( cxScanConfig : CxConfig , logFilePath ?: string , type ?: string ) : Promise < CxWrapper > {
66 let wrapper : CxWrapper ;
7-
7+ wrapper = await CxWrapper . getInstance ( cxScanConfig , logFilePath ) ;
88 if ( type === 'mock' ) {
9- wrapper = new CxWrapper ( cxScanConfig , logFilePath ) ;
10- } else {
11- wrapper = await CxWrapper . getInstance ( cxScanConfig , logFilePath ) ;
9+ wrapper = wrapper . cloneWithNewConfig ( cxScanConfig ) ;
1210 }
1311 await wrapper . init ( ) ;
1412 return wrapper ;
You can’t perform that action at this time.
0 commit comments