66 Command ,
77 commandComment ,
88 runBashCommand ,
9+ runCommand ,
910 StepResponse ,
1011} from "src/main" ;
1112import convert from "xml-js" ;
@@ -29,15 +30,16 @@ export const testing = async (
2930 command : Command ,
3031 testResultsPath : string ,
3132) : Promise < StepResponse > => {
32- let response : StepResponse = { output : "" , error : false } ;
33- let outputStr = "" ;
34- try {
35- await exec ( command . command ) ;
36- } catch ( error ) {
37- response . error = true ;
38- setFailed ( `Failed ${ command . label } : ${ error as string } ` ) ;
39- }
40- console . log ( command . command ) ;
33+ // let response: StepResponse = { output: "", error: false };
34+ // let outputStr = "";
35+ // try {
36+ // await exec(command.command);
37+ // } catch (error) {
38+ // response.error = true;
39+ // setFailed(`Failed ${command.label}: ${error as string}`);
40+ // }
41+
42+ let [ response , outputStr ] = await runCommand ( command ) ;
4143
4244 let testResults = "" ;
4345 let failedToReadFile = false ;
@@ -56,12 +58,7 @@ export const testing = async (
5658 convert . xml2json ( testResults , { compact : false , spaces : 2 } ) ,
5759 ) ;
5860
59- // fs.writeFileSync(
60- // "src/test/testResults.json",
61- // convert.xml2json(testResults, { compact: true, spaces: 2 }),
62- // );
63-
64- outputStr +=
61+ outputStr =
6562 "<table><tr><th>File</th><th>Test Name</th><th>Line</th><th>Type</th><th>Message</th></tr>" ;
6663
6764 const testSuites = jsonResults [ "elements" ] [ 0 ] [ "elements" ] ;
@@ -94,6 +91,7 @@ export const testing = async (
9491 outputStr = "Test Run Failed" ;
9592 }
9693 }
94+
9795 return await buildComment ( response , command . label , outputStr , problemCount ) ;
9896} ;
9997
@@ -113,6 +111,9 @@ export const typeDoc = async (command: Command): Promise<StepResponse> => {
113111 setFailed ( `Failed ${ command . label } : ${ error as string } ` ) ;
114112 }
115113
114+ let outputStr = "" ;
115+ let problemCount = 0 ;
116+
116117 if ( response . error ) {
117118 commandOutput = commandOutput . replace ( / \[ \d + m / g, "" ) ;
118119 const lines = commandOutput . split ( "\n" ) ;
@@ -126,18 +127,16 @@ export const typeDoc = async (command: Command): Promise<StepResponse> => {
126127 return "" ;
127128 } )
128129 . join ( "" ) ;
129- const outputStr = `<table><tr><th>File</th><th>Line</th><th>Column</th><th>Message</th></tr>${ table } </table>` ;
130+ outputStr = `<table><tr><th>File</th><th>Line</th><th>Column</th><th>Message</th></tr>${ table } </table>` ;
130131
131- let problemCount = 0 ;
132132 lines . forEach ( ( line ) => {
133133 const match = line . match ( / F o u n d ( \d + ) e r r o r s a n d ( \d + ) w a r n i n g s / ) ;
134134 if ( match ) {
135135 const [ _ , errors , warnings ] = match ;
136136 problemCount += parseInt ( errors ) + parseInt ( warnings ) ;
137137 }
138138 } ) ;
139-
140- return await buildComment ( response , command . label , outputStr , problemCount ) ;
141139 }
142- return await buildComment ( response , command . label ) ;
140+
141+ return await buildComment ( response , command . label , outputStr , problemCount ) ;
143142} ;
0 commit comments