Skip to content

Commit fb63443

Browse files
committed
Condensed search()
1 parent 6a12ef7 commit fb63443

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

utils/bump/bump-utils.mjs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,13 @@ export function findFileBySuffix({
6262
;(function search(currentDir) {
6363
for (const entry of fs.readdirSync(currentDir)) {
6464
const entryPath = path.join(currentDir, entry), stat = fs.statSync(entryPath)
65-
if (entry == 'node_modules'
66-
|| (entry.startsWith('.') && !dotFolders && stat.isDirectory()) // dotfolder but disabled
67-
) continue // skip it
68-
if (stat.isDirectory() && recursive) search(entryPath)
69-
else if (stat.isFile() && entry.endsWith(suffix) // file w/ `suffix`
70-
&& (dotFiles || !entry.startsWith('.')) // not dotfile if disabled
71-
&& !ignoreFiles.includes(entry) // not ignored file
72-
) { foundFiles.push(entryPath) ; if (verbose) console.log(entryPath) }
65+
if (stat.isDirectory()) {
66+
if (entry == 'node_modules' || (entry.startsWith('.') && !dotFolders)) continue
67+
if (recursive) search(entryPath)
68+
} else if (stat.isFile()) {
69+
if (ignoreFiles.includes(entry) || (entry.startsWith('.') && !dotFiles)) continue
70+
if (entry.endsWith(suffix)) { foundFiles.push(entryPath) ; if (verbose) console.log(entryPath) }
71+
}
7372
}
7473
})(path.resolve(dir))
7574
return foundFiles

0 commit comments

Comments
 (0)