Skip to content

Commit

Permalink
Handle globs on missing directories
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed May 5, 2023
1 parent ef332a4 commit 4b020ca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 9 additions & 6 deletions coursier/cputil/ClassPathUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ object ClassPathUtil {
value
}
def allJarsOf(dir: Path): Seq[Path] =
Files.list(dir)
.iterator
.asScala
.filter(_.toString.endsWithIgnoreCase(".jar"))
.toVector
.sortBy(_.getFileName)
if (Files.isDirectory(dir))
Files.list(dir)
.iterator
.asScala
.filter(_.toString.endsWithIgnoreCase(".jar"))
.toVector
.sortBy(_.getFileName)
else
Nil
val allJarsSuffixes = Seq("/", File.separator)
.distinct
.flatMap(sep => Seq("*", "*.jar").map(sep + _))
Expand Down
12 changes: 12 additions & 0 deletions test/coursier/cputil/tests/ClassPathUtilTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ class ClassPathUtilTests extends munit.FunSuite {
}
}

test("star missing dir") {
val tmpDir = os.temp.dir(prefix = "class-path-util-tests")

val sep = File.separator

for (glob <- testGlobs) {
val res =
ClassPathUtil.classPath(s"${tmpDir / "foo"}$sep$glob", _ => None).map(os.Path(_, os.pwd))
expect(res.isEmpty)
}
}

test("property") {
val initialCp = os.proc("cs", "fetch", "org.scala-lang:scala3-compiler_3:3.1.3")
.call()
Expand Down

0 comments on commit 4b020ca

Please sign in to comment.