Skip to content

Commit 599e42f

Browse files
authored
Helper to find all config files (#14)
1 parent e39c850 commit 599e42f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ libraryDependencies ++= Seq(
2020
"com.typesafe.play" %% "play-json" % "2.4.8",
2121
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
2222
"com.codacy" %% "codacy-plugins-api" % "1.0.8" withSources(),
23-
"com.github.pathikrit" %% "better-files" % "2.14.0" withSources()
23+
"com.github.pathikrit" %% "better-files" % "2.17.1" withSources()
2424
)
2525

2626
organizationName := "Codacy"

src/main/scala/codacy/dockerApi/utils/FileHelper.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,15 @@ object FileHelper {
3636
(these ++ these.filter(_.isDirectory).flatMap(recursiveListFiles)).toList
3737
}
3838

39+
def findConfigurationFile(candidates: Set[String], path: Path): Option[Path] = {
40+
candidates.flatMap { nativeConfigFileName =>
41+
better.files.File(path).listRecursively
42+
.filter(f => f.name == nativeConfigFileName)
43+
.map(_.path)
44+
}
45+
.to[List]
46+
.sortBy(_.toString.length)
47+
.headOption
48+
}
49+
3950
}

0 commit comments

Comments
 (0)