Skip to content

Commit

Permalink
use flatMap
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskfla committed Jun 19, 2024
1 parent 92bb784 commit 0c26dd8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/types/generate-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ const settings: TJS.PartialArgs = {

function getTsFiles(dir: string): string[] {
const dirContents = fs.readdirSync(dir);
const files = dirContents
.map(dirItem => {
const res = resolve(dir, dirItem);
return fs.statSync(res).isDirectory() ? getTsFiles(res) : res;
})
.flat();
const files = dirContents.flatMap(dirItem => {
const res = resolve(dir, dirItem);
return fs.statSync(res).isDirectory() ? getTsFiles(res) : res;
});

return files.filter(fileName => fileName.endsWith('.ts'));
}
Expand Down

0 comments on commit 0c26dd8

Please sign in to comment.