Skip to content

Commit 3545d94

Browse files
committed
fix integration tests, branch required
1 parent 3ecaf08 commit 3545d94

File tree

1 file changed

+42
-38
lines changed

1 file changed

+42
-38
lines changed

src/main/wrapper/ExecutionService.ts

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class ExecutionService {
3333
return new Promise(function (resolve, reject) {
3434
let stderr = '';
3535
let cxCommandOutput = new CxCommandOutput();
36+
let output_string ="";
3637
commands = transformation(commands);
3738
const cp = spawn(pathToExecutable, commands);
3839
cp.stderr.on('data', function (chunk: string) {
@@ -48,50 +49,53 @@ export class ExecutionService {
4849
});
4950
cp.stdout.on('data', (data: any) => {
5051
if (data) {
51-
logger.info(`${data.toString().trim()}`);
52-
if (isJsonString(data.toString())) {
53-
let resultObject = JSON.parse(data.toString().split('\n')[0]);
54-
// Some cli outputs have array format, must be checked
55-
if (resultObject instanceof Array) {
56-
// Check if there is a specific type for the output and make conversions
57-
switch(output){
58-
case 'CxScan':
59-
let r = resultObject.map((member)=>{return Object.assign( new CxScan(),member);}) ;
60-
cxCommandOutput.payload = r;
61-
break;
62-
case 'CxProject':
63-
r = resultObject.map((member)=>{return Object.assign( new CxProject(),member);}) ;
64-
cxCommandOutput.payload = r;
65-
break;
66-
default:
67-
logger.info(JSON.stringify(resultObject));
68-
cxCommandOutput.payload = resultObject;
69-
}
70-
} else {
71-
let resultArray: any [] = [];
72-
// Check if there is a specific type for the output and make conversions
73-
switch(output){
74-
case 'CxScan':
75-
let r = Object.assign( new CxScan(),resultObject);
76-
resultArray.push(r);
77-
cxCommandOutput.payload = resultArray;
78-
break;
79-
case 'CxProject':
80-
r = Object.assign( new CxProject(),resultObject);
81-
resultArray.push(r);
82-
cxCommandOutput.payload = resultArray;
83-
break;
84-
default:
85-
resultArray.push(resultObject);
86-
cxCommandOutput.payload = resultArray;
87-
}
52+
output_string+=data;
53+
}
54+
});
55+
cp.stdout.on('close', (data: any) => {
56+
console.log("fim",output_string);
57+
logger.info(`${output_string.toString().trim()}`);
58+
if (isJsonString(output_string.toString())) {
59+
let resultObject = JSON.parse(output_string.toString().split('\n')[0]);
60+
// Some cli outputs have array format, must be checked
61+
if (resultObject instanceof Array) {
62+
// Check if there is a specific type for the output and make conversions
63+
switch(output){
64+
case 'CxScan':
65+
let r = resultObject.map((member)=>{return Object.assign( new CxScan(),member);}) ;
66+
cxCommandOutput.payload = r;
67+
break;
68+
case 'CxProject':
69+
r = resultObject.map((member)=>{return Object.assign( new CxProject(),member);}) ;
70+
cxCommandOutput.payload = r;
71+
break;
72+
default:
73+
logger.info(JSON.stringify(resultObject));
74+
cxCommandOutput.payload = resultObject;
75+
}
76+
} else {
77+
let resultArray: any [] = [];
78+
// Check if there is a specific type for the output and make conversions
79+
switch(output){
80+
case 'CxScan':
81+
let r = Object.assign( new CxScan(),resultObject);
82+
resultArray.push(r);
83+
cxCommandOutput.payload = resultArray;
84+
break;
85+
case 'CxProject':
86+
r = Object.assign( new CxProject(),resultObject);
87+
resultArray.push(r);
88+
cxCommandOutput.payload = resultArray;
89+
break;
90+
default:
91+
resultArray.push(resultObject);
92+
cxCommandOutput.payload = resultArray;
8893
}
8994
}
9095
}
9196
});
9297
});
9398
}
94-
9599
executeResultsCommands(pathToExecutable: string, commands: string[]): Promise<CxCommandOutput> {
96100
return new Promise(function (resolve, reject) {
97101
let stderr = '';

0 commit comments

Comments
 (0)