@@ -12,7 +12,7 @@ async function checkTerraform () {
1212 return io . which ( pathToCLI , check ) ;
1313}
1414
15- ( async ( ) => {
15+ async ( ) => {
1616 // This will fail if Terraform isn't found, which is what we want
1717 await checkTerraform ( ) ;
1818
@@ -21,14 +21,14 @@ async function checkTerraform () {
2121 const stderr = new OutputListener ( ) ;
2222 const listeners = {
2323 stdout : stdout . listener ,
24- stderr : stderr . listener
24+ stderr : stderr . listener ,
2525 } ;
2626
2727 // Execute terraform and capture output
2828 const args = process . argv . slice ( 2 ) ;
2929 const options = {
3030 listeners,
31- ignoreReturnCode : true
31+ ignoreReturnCode : true ,
3232 } ;
3333 const exitCode = await exec ( pathToCLI , args , options ) ;
3434 core . debug ( `Terraform exited with code ${ exitCode } .` ) ;
@@ -37,13 +37,18 @@ async function checkTerraform () {
3737 core . debug ( `exitcode: ${ exitCode } ` ) ;
3838
3939 // Set outputs, result, exitcode, and stderr
40- core . setOutput ( ' stdout' , stdout . contents ) ;
41- core . setOutput ( ' stderr' , stderr . contents ) ;
42- core . setOutput ( ' exitcode' , exitCode . toString ( 10 ) ) ;
40+ core . setOutput ( " stdout" , stdout . contents ) ;
41+ core . setOutput ( " stderr" , stderr . contents ) ;
42+ core . setOutput ( " exitcode" , exitCode . toString ( 10 ) ) ;
4343
44- // A non-zero exitCode is considered an error
45- // An exit-code 2 may be returned when the '-detailed-exitcode' option is passed to plan. This denotes Success with non-empty diff (changes present).
46- if ( exitCode !== 0 || exitCode !== 2 ) {
47- core . setFailed ( `Terraform exited with code ${ exitCode } .` ) ;
44+ if ( exitCode === 0 || exitCode === 2 ) {
45+ // A exitCode of 0 is considered a success
46+ // An exitCode of 2 may be returned when the '-detailed-exitcode' option
47+ // is passed to plan. This denotes Success with non-empty
48+ // diff (changes present).
49+ return ;
4850 }
49- } ) ( ) ;
51+
52+ // A non-zero exitCode is considered an error
53+ core . setFailed ( `Terraform exited with code ${ exitCode } .` ) ;
54+ } ;
0 commit comments