@@ -9,28 +9,30 @@ import {LogUtils, SwerrConfig, SwerrScheme} from "@swerr/core";
99
1010export const runCommand = async ( configPath : string | undefined ) => {
1111 const swerrConfig = await config ( configPath ) ;
12- const sourceDir = swerrConfig ?. sourceFile ?. inputDir || null
12+ const sourceDirs = swerrConfig ?. sourceFile ?. inputDirs || null
1313 const outputDir = swerrConfig ?. sourceFile ?. export ?. outputDir || null
1414
1515 if ( ! swerrConfig ) {
1616 LogUtils . error ( `Swerr configuration file not found. Please create a ${ SWERR_CONFIG_FILE } file in the current directory or specify a custom path using --config option.` ) ;
1717 process . exit ( 1 ) ;
1818 }
1919
20- if ( ! sourceDir || ! outputDir ) {
20+ if ( ! sourceDirs || sourceDirs . length === 0 || ! outputDir ) {
2121 LogUtils . error ( "Source and output directories must be specified either via configuration file." ) ;
2222 process . exit ( 1 ) ;
2323 }
2424
2525 LogUtils . success ( "Swerr Configuration loaded." ) ;
2626
27- const absoluteSourceDir = path . resolve ( process . cwd ( ) , sourceDir ) ;
2827 const absoluteOutputDir = path . resolve ( process . cwd ( ) , outputDir ) ;
2928
30- const sourceExists = fs . existsSync ( absoluteSourceDir ) ;
31- if ( ! sourceExists ) {
32- LogUtils . error ( `Source directory "${ absoluteSourceDir } " does not exist.` ) ;
33- process . exit ( 1 ) ;
29+ for ( const sourceDir of sourceDirs ) {
30+ const absoluteSourceDir = path . resolve ( process . cwd ( ) , sourceDir ) ;
31+ const sourceExists = fs . existsSync ( absoluteSourceDir ) ;
32+ if ( ! sourceExists ) {
33+ LogUtils . error ( `Source directory "${ absoluteSourceDir } " does not exist.` ) ;
34+ process . exit ( 1 ) ;
35+ }
3436 }
3537
3638 try {
@@ -40,15 +42,26 @@ export const runCommand = async (configPath: string | undefined) => {
4042 process . exit ( 1 ) ;
4143 }
4244
43- scanJsdocs ( absoluteSourceDir , swerrConfig ?. sourceFile . options || { } ) . then ( async result => {
44- LogUtils . info ( `Scanned ${ result . blocks . length } JSDocs block(s) from ${ result . scannedFiles } file(s).` ) ;
45- const scheme = translateToSourceScheme ( result , swerrConfig )
45+ try {
46+ const scanOptions = swerrConfig ?. sourceFile . options || { } ;
47+ const mergedResult = { rootDir : sourceDirs [ 0 ] , blocks : [ ] as any [ ] , scannedFiles : 0 , skippedFiles : 0 } ;
48+
49+ for ( const sourceDir of sourceDirs ) {
50+ const absoluteSourceDir = path . resolve ( process . cwd ( ) , sourceDir ) ;
51+ const result = await scanJsdocs ( absoluteSourceDir , scanOptions ) ;
52+ mergedResult . blocks . push ( ...result . blocks ) ;
53+ mergedResult . scannedFiles += result . scannedFiles ;
54+ mergedResult . skippedFiles += result . skippedFiles ;
55+ }
56+
57+ LogUtils . info ( `Scanned ${ mergedResult . blocks . length } JSDocs block(s) from ${ mergedResult . scannedFiles } file(s).` ) ;
58+ const scheme = translateToSourceScheme ( mergedResult , swerrConfig )
4659 LogUtils . info ( `Translated scan result to swerr Scheme with ${ scheme . errors . length } error(s).` ) ;
4760 await saveSourceScheme ( swerrConfig ! , absoluteOutputDir , scheme ) ;
4861 await runConverter ( swerrConfig ! , scheme ) ;
49- } ) . catch ( err => {
62+ } catch ( err ) {
5063 LogUtils . error ( `Error during scanning: ${ err } ` ) ;
51- } )
64+ }
5265}
5366
5467async function config ( configPath : string | undefined ) : Promise < SwerrConfig | null > {
0 commit comments