File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,27 @@ module.exports = class RelationGenerator extends ArtifactGenerator {
230
230
/* istanbul ignore next */
231
231
return this . exit ( err ) ;
232
232
}
233
+ // Check if modelDir contains subdirectories
234
+ const subdirectories = await utils . getSubdirectories (
235
+ this . artifactInfo . modelDir ,
236
+ ) ;
237
+ // If subdirectories exist, retrieve models from them
238
+ if ( subdirectories . length > 0 ) {
239
+ for ( const subdirectory of subdirectories ) {
240
+ try {
241
+ const subdirectoryModelList = await utils . getArtifactList (
242
+ subdirectory ,
243
+ 'model' ,
244
+ ) ;
245
+ modelList = modelList . concat ( subdirectoryModelList ) ;
246
+ } catch ( err ) {
247
+ // Handle errors for subdirectory model retrieval
248
+ console . error (
249
+ `Error retrieving models from subdirectory ${ subdirectory } : ${ err } ` ,
250
+ ) ;
251
+ }
252
+ }
253
+ }
233
254
let repoList ;
234
255
try {
235
256
debug ( `repository list dir ${ this . artifactInfo . repoDir } ` ) ;
Original file line number Diff line number Diff line change @@ -330,6 +330,28 @@ module.exports = class RepositoryGenerator extends ArtifactGenerator {
330
330
return this . exit ( err ) ;
331
331
}
332
332
333
+ // Check if modelDir contains subdirectories
334
+ const subdirectories = await utils . getSubdirectories (
335
+ this . artifactInfo . modelDir ,
336
+ ) ;
337
+ // If subdirectories exist, retrieve models from them
338
+ if ( subdirectories . length > 0 ) {
339
+ for ( const subdirectory of subdirectories ) {
340
+ try {
341
+ const subdirectoryModelList = await utils . getArtifactList (
342
+ subdirectory ,
343
+ 'model' ,
344
+ ) ;
345
+ modelList = modelList . concat ( subdirectoryModelList ) ;
346
+ } catch ( err ) {
347
+ // Handle errors for subdirectory model retrieval
348
+ console . error (
349
+ `Error retrieving models from subdirectory ${ subdirectory } : ${ err } ` ,
350
+ ) ;
351
+ }
352
+ }
353
+ }
354
+
333
355
if ( this . options . model ) {
334
356
debug ( `Model name received from command line: ${ this . options . model } ` ) ;
335
357
Original file line number Diff line number Diff line change 6
6
'use strict' ;
7
7
8
8
const fs = require ( 'node:fs' ) ;
9
+ const fsp = require ( 'fs/promises' ) ;
9
10
const path = require ( 'node:path' ) ;
10
11
const util = require ( 'node:util' ) ;
11
12
const stream = require ( 'node:stream' ) ;
@@ -383,6 +384,21 @@ exports.getArtifactList = async function (
383
384
} ) ;
384
385
} ;
385
386
387
+ /**
388
+ * Retrieves a list of subdirectories within a given directory.
389
+ *
390
+ * @param {string } dir The directory path to search for subdirectories.
391
+ */
392
+ exports . getSubdirectories = async function ( dir ) {
393
+ const entries = await fsp . readdir ( dir , { withFileTypes : true } ) ;
394
+
395
+ const subdirectories = entries
396
+ . filter ( entry => entry . isDirectory ( ) )
397
+ . map ( entry => path . join ( dir , entry . name ) ) ;
398
+
399
+ return subdirectories ;
400
+ } ;
401
+
386
402
/**
387
403
* Check package.json and dependencies.json to find out versions for generated
388
404
* dependencies
You can’t perform that action at this time.
0 commit comments