@@ -52,25 +52,39 @@ executeSynchronous(async () => {
5252 await mkdir ( outputBaseDir , { recursive : true } ) ;
5353 const subdirsCreated = new Set < string > ( ) ;
5454 const summaryLogger = await getLogger ( `${ outputBaseDir } /summary.log` ) ;
55+ const getBasePath = ( readmePath : string ) => path . relative ( specsPath , readmePath ) . split ( path . sep ) [ 0 ] . toLowerCase ( ) ;
56+
57+ const basePathData = readmePaths
58+ // use sorting to ensure determinism
59+ . sort ( lowerCaseCompare )
60+ . map ( readmePath => ( { readmePath, basePath : getBasePath ( readmePath ) } ) )
61+ . filter ( x => ! singlePath || lowerCaseCompare ( singlePath , x . basePath ) === 0 ) ;
62+
63+ const pathData = basePathData . map ( entry => {
64+ const { readmePath, basePath } = entry ;
65+ const readmesInBasePath = basePathData . filter ( x => x . basePath === basePath ) ;
66+ const outputBasePath = readmesInBasePath . length > 0 ? `${ basePath } _${ readmesInBasePath . indexOf ( entry ) } ` : basePath ;
67+
68+ return {
69+ readmePath,
70+ relativeReadmePath : path . relative ( inputBaseDir , readmePath ) ,
71+ bicepReadmePath : `${ path . dirname ( readmePath ) } /readme.bicep.md` ,
72+ config : getConfig ( basePath ) ,
73+ tmpOutputDir : `${ tmpOutputPath } /${ outputBasePath } ` ,
74+ outputDir : `${ outputBaseDir } /${ outputBasePath } ` ,
75+ } ;
76+ } ) ;
5577
56- // use consistent sorting to make log changes easier to review
57- for ( const readmePath of readmePaths . sort ( lowerCaseCompare ) ) {
58- const bicepReadmePath = `${ path . dirname ( readmePath ) } /readme.bicep.md` ;
59- const basePath = path . relative ( specsPath , readmePath ) . split ( path . sep ) [ 0 ] . toLowerCase ( ) ;
60- const tmpOutputDir = `${ tmpOutputPath } /${ basePath } ` ;
61- const outputDir = `${ outputBaseDir } /${ basePath } ` ;
62-
63- if ( singlePath && lowerCaseCompare ( singlePath , basePath ) !== 0 ) {
64- continue ;
65- }
66-
78+ for ( const entry of pathData ) {
79+ const { readmePath, relativeReadmePath, bicepReadmePath, config, tmpOutputDir, outputDir } = entry ;
6780 // prepare temp dir for output
6881 await rm ( tmpOutputDir , { recursive : true , force : true , } ) ;
6982 await mkdir ( tmpOutputDir , { recursive : true } ) ;
7083 const logger = await getLogger ( `${ tmpOutputDir } /log.out` ) ;
71- const config = getConfig ( basePath ) ;
7284
7385 try {
86+ logger . out ( `Generating types for '${ relativeReadmePath } '\n` ) ;
87+
7488 // autorest readme.bicep.md files are not checked in, so we must generate them before invoking autorest
7589 await generateAutorestConfig ( logger , readmePath , bicepReadmePath , config ) ;
7690 await runAutorest ( logger , readmePath , tmpOutputDir , logLevel , waitForDebugger ) ;
@@ -88,7 +102,7 @@ executeSynchronous(async () => {
88102 // Use markdown formatting as this summary will be included in the PR description
89103 logOut ( summaryLogger ,
90104`<details>
91- <summary>Failed to generate types for path '${ basePath } '</summary>
105+ <summary>Failed to generate types for '${ relativeReadmePath } '</summary>
92106
93107\`\`\`
94108${ err }
0 commit comments