@@ -40,9 +40,9 @@ export async function analyze(): Promise<void> {
4040 POLICY ,
4141 ] ;
4242
43- const getArgs = ( cmd : string ) => [
43+ const getArgs = ( cmd : string [ ] ) => [
4444 CONTAINER ? 'container' : null ,
45- cmd ,
45+ ... cmd ,
4646 ...getEndpointArgs ( ) ,
4747 ...getBranchArgs ( ) ,
4848 ...getProjectArgs ( ) ,
@@ -68,15 +68,15 @@ export async function analyze(): Promise<void> {
6868
6969 if ( ! RUN_TESTS ) {
7070 output = '' ;
71- const exitCode = await exec ( 'fossa' , [ ...getArgs ( 'analyze' ) , CONTAINER ] , defaultOptions ) ;
71+ const exitCode = await exec ( 'fossa' , [ ...getArgs ( [ 'analyze' ] ) , CONTAINER ] , defaultOptions ) ;
7272
7373 // Check output or exitCode
7474 if ( exitCode !== 0 || output . match ( failedRegex ) ) {
7575 throw new Error ( `FOSSA failed to scan` ) ;
7676 }
7777 } else if ( RUN_TESTS ) {
7878 output = '' ;
79- const args = [ ...getArgs ( 'test' ) , CONTAINER ] ;
79+ const args = [ ...getArgs ( [ 'test' ] ) , CONTAINER ] ;
8080
8181 if ( TEST_DIFF_REV && TEST_DIFF_REV !== '' ) {
8282 args . push ( '--diff' , TEST_DIFF_REV ) ;
@@ -105,37 +105,40 @@ export async function report(): Promise<void> {
105105 REPORT_FORMAT ,
106106 ] ;
107107
108- const getArgs = ( cmd : string ) => [
109- cmd ,
108+ const getArgs = ( cmd : string [ ] ) => [
109+ ... cmd ,
110110 ...getEndpointArgs ( ) ,
111111 ...getProjectArgs ( ) ,
112112 ...getFormatArgs ( ) ,
113113 DEBUG ? '--debug' : null ,
114114 ] . filter ( arg => arg ) ;
115115
116116 // Setup listeners
117- let output ;
118- const collectOutput = ( data : Buffer ) => {
119- output += data . toString ( ) ;
117+ let stdout = '' ;
118+ let stderr = '' ;
119+ const collectStdout = ( data : Buffer ) => {
120+ stdout += data . toString ( ) ;
121+ } ;
122+ const collectStderr = ( data : Buffer ) => {
123+ stderr += data . toString ( ) ;
120124 } ;
121125
122126 const listeners : ExecListeners = {
123- stdout : collectOutput ,
124- stderr : collectOutput ,
127+ stdout : collectStdout ,
128+ stderr : collectStderr ,
125129 } ;
126130
127131 // Collect default options: Env and listeners
128132 const PATH = process . env . PATH || '' ;
129133 const defaultOptions = { env : { ...process . env , PATH , FOSSA_API_KEY } , listeners } ;
130- output = '' ;
131- const exitCode = await exec ( 'fossa' , [ ...getArgs ( 'report attribution' ) ] , defaultOptions ) ;
134+ const exitCode = await exec ( 'fossa' , getArgs ( [ 'report' , 'attribution' ] ) , defaultOptions ) ;
132135
133136 // Check output or exitCode
134- if ( exitCode !== 0 || output . match ( failedRegex ) ) {
137+ if ( exitCode !== 0 || stderr . match ( failedRegex ) ) {
135138 throw new Error ( `FOSSA failed to scan` ) ;
136139 }
137140
138- setOutput ( 'report' , output ) ;
141+ setOutput ( 'report' , stdout ) ;
139142}
140143
141144async function run ( ) {
@@ -147,7 +150,7 @@ async function run() {
147150
148151 try {
149152 await analyze ( ) ;
150- if ( REPORT_FORMAT ?. length ) {
153+ if ( REPORT_FORMAT ?. length ) {
151154 await report ( ) ;
152155 }
153156 } catch ( e ) {
0 commit comments