Skip to content

Commit 6c37f42

Browse files
committed
make CxWrapper constructor private
1 parent 2a4c32d commit 6c37f42

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/wrapper/CxWrapper.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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();

src/main/wrapper/CxWrapperFactory.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import {CxConfig} from "./CxConfig";
44
class 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;

0 commit comments

Comments
 (0)