Skip to content

Commit

Permalink
Add a recursive property to Source
Browse files Browse the repository at this point in the history
Required to fix sbt/sbt#3501.
  • Loading branch information
dwijnand committed Oct 12, 2017
1 parent e5c627b commit eac1937
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions io/src/main/scala/sbt/internal/io/SourceModificationWatch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,17 @@ private[sbt] final class WatchState private (
* @param base Where to start looking for files.
* @param includeFilter Filter to apply to determine whether to include a file.
* @param excludeFilter Filter to apply to determine whether to ignore a file.
* @param recursive Whether the lists is recursive or immediate children.
*/
final class Source(base: File, includeFilter: FileFilter, excludeFilter: FileFilter) {
final class Source(
base: File,
includeFilter: FileFilter,
excludeFilter: FileFilter,
recursive: Boolean
) {

def this(base: File, includeFilter: FileFilter, excludeFilter: FileFilter) =
this(base, includeFilter, excludeFilter, true)

/**
* Determine whether `p` should be included in this source.
Expand All @@ -151,8 +160,13 @@ final class Source(base: File, includeFilter: FileFilter, excludeFilter: FileFil
* Gathers all the paths from this source without applying filters.
* @return A sequence of all the paths collected from this source.
*/
private[sbt] def getUnfilteredPaths(): Seq[Path] =
base.allPaths.get.map(_.toPath)
private[sbt] def getUnfilteredPaths(): Seq[Path] = {
val pathFinder = if (recursive) base.allPaths else base.glob(AllPassFilter)
pathFinder.get.map(_.toPath)
}

def withRecursive(recursive: Boolean): Source =
new Source(base, includeFilter, excludeFilter, recursive)

}

Expand Down

0 comments on commit eac1937

Please sign in to comment.