Skip to content

Commit

Permalink
refactor(npm): Reduce the amount of filterTo()s
Browse files Browse the repository at this point in the history
Keep `searchDirs` as a `Sequence`.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Oct 9, 2024
1 parent 8b07534 commit dc5fc90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/package-managers/node/src/main/kotlin/Npm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ open class Npm(
val nodeModulesDir = moduleDir.resolve("node_modules")
if (!nodeModulesDir.isDirectory) return emptyList()

val searchDirs = nodeModulesDir.walk().maxDepth(1).filterTo(mutableListOf()) {
val searchDirs = nodeModulesDir.walk().maxDepth(1).filter {
(it.isDirectory && it.name.startsWith("@")) || it == nodeModulesDir
}

return searchDirs.flatMap { dir ->
dir.walk().maxDepth(1).filterTo(mutableListOf()) {
return searchDirs.flatMapTo(mutableListOf()) { dir ->
dir.walk().maxDepth(1).filter {
it.isDirectory && it.isSymbolicLink() && it != dir
}
}
Expand Down

0 comments on commit dc5fc90

Please sign in to comment.