Skip to content

Commit

Permalink
Run scalafmt (ScalablyTyped#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
steinybot committed Jul 29, 2024
1 parent cdf4316 commit 236bc13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import scala.util.Try
object GlobWalker {

/**
* Traverses the base directory and returns all files that match a given glob.
*
* Only returns files, not directories. If a directory matches a glob then all its descendents are included.
*
* @see the glob syntax in [[java.nio.file.FileSystem#getPathMatcher]]
*/
* Traverses the base directory and returns all files that match a given glob.
*
* Only returns files, not directories. If a directory matches a glob then all its descendents are included.
*
* @see the glob syntax in [[java.nio.file.FileSystem#getPathMatcher]]
*/
def walkFiles(baseDirectory: os.Path, globs: IArray[String]): IndexedSeq[os.Path] = {
val pathOrMatchers = globs.map { glob =>
Try(FileSystems.getDefault.getPathMatcher(s"glob:$glob")).toOption.toRight(baseDirectory / glob)
Expand All @@ -30,15 +30,14 @@ object GlobWalker {

val builder = IndexedSeq.newBuilder[os.Path]

def processDirectoryAndSkip(dir: os.Path): Boolean = {
def processDirectoryAndSkip(dir: os.Path): Boolean =
if (matches(dir)) {
os.walk.stream(dir).generate { path =>
if (path.toIO.isFile) builder += path
Generator.Continue
}
true
} else false
}

os.walk.stream(baseDirectory, processDirectoryAndSkip).generate { path =>
if (path.toIO.isFile && matches(path)) builder += path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object LibTsSource {

def fromFilesGlobEntry(fromFolder: LibTsSource.FromFolder, globs: Option[IArray[String]]): IArray[InFile] = {
val baseDirectory = fromFolder.folder.path
val files = globs.fold(os.walk(baseDirectory))(GlobWalker.walkFiles(baseDirectory, _)).map(InFile(_))
val files = globs.fold(os.walk(baseDirectory))(GlobWalker.walkFiles(baseDirectory, _)).map(InFile(_))
IArray.fromTraversable(files)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Phase1ReadTypescript(
f.shortenedFiles
case f: LibTsSource.FromFolder =>
/* There are often whole trees parallel to what is specified in `typings` (or similar). This ignores some of them. */
val bound = f.shortenedFiles.map(_.folder).distinct
val bound = f.shortenedFiles.map(_.folder).distinct
val boundOrParent = if (bound.isEmpty) IArray(f.folder) else bound
boundOrParent.flatMap(PathsFromTsLibSource.filesFrom).distinct
}
Expand Down

0 comments on commit 236bc13

Please sign in to comment.