@@ -6,7 +6,7 @@ import { ComponentDiagramGenerator } from './plantuml/ComponentDiagramGenerator.
66import { CancellationToken } from 'vscode-languageserver'
77
88export class PlantUMLGenerator implements ContextMapperGenerator {
9- async generate ( model : ContextMappingModel , filePath : string , args : unknown [ ] , cancelToken : CancellationToken ) : Promise < string | undefined > {
9+ async generate ( model : ContextMappingModel , filePath : string , args : unknown [ ] , cancelToken : CancellationToken ) : Promise < string [ ] | undefined > {
1010 // there must not be any extra spaces especially at the start, since the path will be treated as relative otherwise
1111 const destination = ( args [ 0 ] as string ) ?. trim ( )
1212 if ( destination == null || destination === '' ) {
@@ -23,24 +23,30 @@ export class PlantUMLGenerator implements ContextMapperGenerator {
2323 await fs . promises . mkdir ( destination , { recursive : true } )
2424 }
2525
26- await this . generateComponentDiagram ( model , destination , fileName )
26+ const diagrams : string [ ] = [ ]
27+
28+ const componentDiagram = await this . generateComponentDiagram ( model , destination , fileName )
29+ if ( componentDiagram ) {
30+ diagrams . push ( componentDiagram )
31+ }
2732
2833 console . log ( 'Successfully generated PlantUML diagrams' )
29- return destination
34+ return diagrams
3035 }
3136
32- private async generateComponentDiagram ( model : ContextMappingModel , destination : string , fileName : string ) {
37+ private async generateComponentDiagram ( model : ContextMappingModel , destination : string , fileName : string ) : Promise < string | undefined > {
3338 if ( model . contextMap . length === 0 ) {
3439 return
3540 }
3641
3742 const generator = new ComponentDiagramGenerator ( )
3843 const diagram = generator . createDiagram ( model . contextMap [ 0 ] )
39- await this . createFile ( destination , fileName , diagram )
44+ return await this . createFile ( destination , fileName , diagram )
4045 }
4146
4247 private async createFile ( destination : string , fileName : string , content : string ) {
4348 const filePath = `${ path . join ( destination , fileName ) } .puml`
4449 await fs . promises . writeFile ( filePath , content )
50+ return filePath
4551 }
4652}
0 commit comments