@@ -4,12 +4,8 @@ import * as taskLib from 'azure-pipelines-task-lib/task';
44import * as toolLib from 'azure-pipelines-tool-lib/tool' ;
55import glob from 'glob' ;
66
7- export function getArgumentList ( sourceDirectory : string ) : string [ ] {
8- const args : Array < string > = new Array < string > ( ) ;
9- args . push ( 'build' ) ;
10- const files = glob . sync ( sourceDirectory ) ;
11- const finalArgs = args . concat ( files ) ;
12- return finalArgs ;
7+ export function getFilesList ( sourceDirectory : string ) : string [ ] {
8+ return glob . sync ( sourceDirectory ) ;
139}
1410
1511async function run ( ) {
@@ -20,7 +16,7 @@ async function run() {
2016 throw new Error ( "The variable 'sourceDirectory' is mandatory." ) ;
2117 }
2218
23- let bicepTool ;
19+ let bicepTool : any ;
2420 const bicepToolName = taskLib . getVariable ( 'BICEP_TOOL_NAME' ) ;
2521 const bicepToolVersion = taskLib . getVariable ( 'BICEP_TOOL_VERSION' ) ;
2622 try {
@@ -45,15 +41,22 @@ async function run() {
4541 ' before this task or ensure Bicep is installed and available in PATH in the agent' ,
4642 ) ;
4743 }
48- const args = getArgumentList ( sourceDirectory ) ;
44+ const files = getFilesList ( sourceDirectory ) ;
4945
5046 taskLib . debug ( 'Running Bicep build...' ) ;
5147
5248 if ( bicepTool ) {
53- const bicepProcess = taskLib . tool ( bicepTool ) . arg ( args ) . execSync ( ) ;
54- if ( bicepProcess . code !== 0 ) {
55- throw new Error ( 'Failed to execute script' ) ;
56- }
49+ files . forEach ( ( file : string ) => {
50+ const args = [ 'build' , file ] ;
51+ const bicepProcess = taskLib . tool ( bicepTool ) . arg ( args ) . execSync ( ) ;
52+
53+ if ( bicepProcess . code !== 0 ) {
54+ throw new Error ( `Failed to execute script. Related file: ${ file } ` ) ;
55+ } else {
56+ taskLib . debug ( `- Built '${ file } ' successfully` ) ;
57+ }
58+ } ) ;
59+
5760 taskLib . debug ( 'Executed successfully' ) ;
5861 } else {
5962 throw new Error ( 'Failed to locate Bicep binary' ) ;
0 commit comments