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 {
17
17
private static semaphore = new Semaphore ( 1 ) ; // Semaphore with 1 slot
18
18
config : CxConfig ;
19
19
cxInstaller : CxInstaller ;
20
- constructor ( cxScanConfig : CxConfig , logFilePath ?: string ) {
20
+ private constructor ( cxScanConfig : CxConfig , logFilePath ?: string ) {
21
21
this . cxInstaller = new CxInstaller ( process . platform ) ;
22
22
this . config = new CxConfig ( ) ;
23
23
getLoggerWithFilePath ( logFilePath )
@@ -62,6 +62,10 @@ export class CxWrapper {
62
62
async init ( ) : Promise < void > {
63
63
return await this . cxInstaller . downloadIfNotInstalledCLI ( ) ;
64
64
}
65
+
66
+ public cloneWithNewConfig ( scanConfig : CxConfig ) : CxWrapper {
67
+ return new CxWrapper ( scanConfig ) ;
68
+ }
65
69
66
70
initializeCommands ( formatRequired : boolean ) : string [ ] {
67
71
this . config . pathToExecutable = this . cxInstaller . getExecutablePath ( ) ;
Original file line number Diff line number Diff line change @@ -4,11 +4,9 @@ import {CxConfig} from "./CxConfig";
4
4
class CxWrapperFactory {
5
5
static async createWrapper ( cxScanConfig : CxConfig , logFilePath ?: string , type ?: string ) : Promise < CxWrapper > {
6
6
let wrapper : CxWrapper ;
7
-
7
+ wrapper = await CxWrapper . getInstance ( cxScanConfig , logFilePath ) ;
8
8
if ( type === 'mock' ) {
9
- wrapper = new CxWrapper ( cxScanConfig , logFilePath ) ;
10
- } else {
11
- wrapper = await CxWrapper . getInstance ( cxScanConfig , logFilePath ) ;
9
+ wrapper = wrapper . cloneWithNewConfig ( cxScanConfig ) ;
12
10
}
13
11
await wrapper . init ( ) ;
14
12
return wrapper ;
You can’t perform that action at this time.
0 commit comments