File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,16 @@ import { PRODUCTION_API_PATH } from "./lib/config";
1212/**
1313 * Recursively removes all files ending in '-internal.yaml' from a directory and its subdirectories
1414 * @param directoryPath - The path to the directory to process
15+ * @param depth - The depth of the directory to process, we limit the depth to 3 to avoid infinite recursion
1516 */
16- export function removeInternalOas ( directoryPath : string ) : void {
17+ export function removeInternalOas ( directoryPath : string , depth = 0 ) : void {
18+ if ( depth > 3 ) {
19+ console . warn (
20+ `Reached maximum depth (${ depth } ) for directory: ${ directoryPath } `
21+ ) ;
22+ return ;
23+ }
24+
1725 if ( ! fs . existsSync ( directoryPath ) ) {
1826 console . warn ( `Directory does not exist: ${ directoryPath } ` ) ;
1927 return ;
@@ -27,7 +35,7 @@ export function removeInternalOas(directoryPath: string): void {
2735
2836 if ( stat . isDirectory ( ) ) {
2937 // Recursively process subdirectories
30- removeInternalOas ( fullPath ) ;
38+ removeInternalOas ( fullPath , depth + 1 ) ;
3139 } else if ( stat . isFile ( ) && item . endsWith ( "-internal.yaml" ) ) {
3240 // Remove internal files
3341 fs . removeSync ( fullPath ) ;
You can’t perform that action at this time.
0 commit comments