Skip to content

Commit

Permalink
fix(intellij): improve finding Nx configuration files (#2352)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Simonchik <sergey.simonchik@jetbrains.com>
  • Loading branch information
MaxKless and segrey authored Dec 9, 2024
1 parent cdf9c46 commit bb2b028
Showing 1 changed file with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package dev.nx.console.utils
import com.intellij.openapi.application.readAction
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectFileIndex
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.VirtualFileVisitor

suspend fun findNxConfigurationFiles(
project: Project,
Expand All @@ -16,22 +15,17 @@ suspend fun findNxConfigurationFiles(
readAction {
val startDirectory = LocalFileSystem.getInstance().findFileByPath(project.nxBasePath)
if (startDirectory != null) {
VfsUtilCore.visitChildrenRecursively(
startDirectory,
object : VirtualFileVisitor<Any?>() {
override fun visitFile(file: VirtualFile): Boolean {
if (
!file.isDirectory &&
(file.name == "project.json" ||
(includeNxJson && file.name == "nx.json"))
) {
paths.add(file)
}
ProgressManager.checkCanceled()
return true
}
ProjectFileIndex.getInstance(project).iterateContentUnderDirectory(startDirectory) {
file ->
if (
!file.isDirectory &&
(file.name == "project.json" || (includeNxJson && file.name == "nx.json"))
) {
paths.add(file)
}
)
ProgressManager.checkCanceled()
return@iterateContentUnderDirectory true
}
}
}
return paths
Expand Down

0 comments on commit bb2b028

Please sign in to comment.