fix recursiveFiles

This commit is contained in:
Roy Cao 2019-12-04 01:05:43 +08:00
parent 5c052f5493
commit ab984c7391
3 changed files with 10 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import Foundation
import Path
public func recursiveFiles(withExtensions exts: [String], at path: Path) throws -> [Path] {
public func recursiveFiles(withExtensions exts: [String], at path: Path) -> [Path] {
if path.isFile {
if exts.contains(path.extension) {
return [path]
@ -9,9 +9,13 @@ public func recursiveFiles(withExtensions exts: [String], at path: Path) throws
return []
} else if path.isDirectory {
var files: [Path] = []
for entry in try path.ls() {
let list = try recursiveFiles(withExtensions: exts, at: entry.path)
files.append(contentsOf: list)
do {
for entry in try path.ls() {
let list = recursiveFiles(withExtensions: exts, at: entry.path)
files.append(contentsOf: list)
}
} catch {
log("failed to path.ls: \(error.localizedDescription)", level: .warning)
}
return files
}

View File

@ -16,7 +16,7 @@ public class SourceCollector {
/// Populates the internal collections form the path source code
/// Currently only supports Swift
func collect() throws {
let files: [Path] = try recursiveFiles(withExtensions: ["swift"], at: path)
let files: [Path] = recursiveFiles(withExtensions: ["swift"], at: path)
for file in files {
let syntax = try SyntaxParser.parse(file.url)
let sourceLocationConverter = SourceLocationConverter(file: file.description, tree: syntax)

View File

@ -21,7 +21,7 @@ fileprivate func main(_ arguments: [String]) -> Int32 {
return 1
}
case .version:
print("0.0.3")
print("0.0.4")
return 0
}
}