Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0.x] Add a recursive property to Source #78

Merged
merged 1 commit into from
Oct 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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