mirror of https://github.com/sbt/sbt.git
fix: Fixes glob in scripted
**Problem** Absolute path handling regressed. **Solution** Create an absolute glob for expression starting with /.
This commit is contained in:
parent
e218c107f0
commit
72c061a2a2
|
|
@ -56,6 +56,11 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
|
||||||
def fromStrings(paths: List[String]) = paths.map(fromString)
|
def fromStrings(paths: List[String]) = paths.map(fromString)
|
||||||
def fromString(path: String) = new File(baseDirectory, path)
|
def fromString(path: String) = new File(baseDirectory, path)
|
||||||
def filterFromStrings(exprs: List[String]): List[PathFilter] = {
|
def filterFromStrings(exprs: List[String]): List[PathFilter] = {
|
||||||
|
def globs(exprs: List[String]): List[PathFilter] =
|
||||||
|
exprs.map { g =>
|
||||||
|
if (g.startsWith("/")) (Glob(g): PathFilter)
|
||||||
|
else (Glob(baseDirectory, g): PathFilter)
|
||||||
|
}
|
||||||
def orGlobs = {
|
def orGlobs = {
|
||||||
val exprs1 = exprs
|
val exprs1 = exprs
|
||||||
.mkString("")
|
.mkString("")
|
||||||
|
|
@ -63,19 +68,18 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler {
|
||||||
.filter(_ != OR)
|
.filter(_ != OR)
|
||||||
.toList
|
.toList
|
||||||
.map(_.trim)
|
.map(_.trim)
|
||||||
val combined = exprs1.map(Glob(baseDirectory, _)) match {
|
val combined = globs(exprs1) match {
|
||||||
case Nil => sys.error("unexpected Nil")
|
case Nil => sys.error("unexpected Nil")
|
||||||
case g :: Nil => (g: PathFilter)
|
case g :: Nil => g
|
||||||
case g :: gs =>
|
case g :: gs =>
|
||||||
gs.foldLeft(g: PathFilter) {
|
gs.foldLeft(g) {
|
||||||
case (acc, g) =>
|
case (acc, g) => acc || g
|
||||||
acc || (g: PathFilter)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List(combined)
|
List(combined)
|
||||||
}
|
}
|
||||||
if (exprs.contains("||")) orGlobs
|
if (exprs.contains("||")) orGlobs
|
||||||
else exprs.map(Glob(baseDirectory, _): PathFilter)
|
else globs(exprs)
|
||||||
}
|
}
|
||||||
|
|
||||||
def touch(paths: List[String]): Unit = IO.touch(fromStrings(paths))
|
def touch(paths: List[String]): Unit = IO.touch(fromStrings(paths))
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,5 @@
|
||||||
-> demo-failure
|
-> demo-failure
|
||||||
> +z
|
> +z
|
||||||
> z
|
> z
|
||||||
|
|
||||||
|
$ absent /tmp/non-existent
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue