Skip to content

Commit

Permalink
added files and started yaml parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
twof committed Oct 23, 2020
1 parent ada1641 commit bfe1d25
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"object": {
"pins": [
{
"package": "Files",
"repositoryURL": "https://github.com/JohnSundell/Files",
"state": {
"branch": null,
"revision": "22fe84797d499ffca911ccd896b34efaf06a50b9",
"version": "4.1.1"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
Expand Down
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import PackageDescription
let package = Package(
name: "Downstream",
dependencies: [
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.0")
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.0"),
.package(url: "https://github.com/JohnSundell/Files", from: "4.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "Downstream",
dependencies: ["Yams"]),
dependencies: ["Yams", "Files"]),
.testTarget(
name: "DownstreamTests",
dependencies: ["Downstream"]),
Expand Down
2 changes: 2 additions & 0 deletions Sources/Downstream/downstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
associations:
main.swift: https://github.com/JohnSundell/Files/blob/master/Sources/Files.swift
20 changes: 19 additions & 1 deletion Sources/Downstream/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Yams
import Files

let yaml = """
associations:
Expand All @@ -17,5 +18,22 @@ associations:
let decoder = YAMLDecoder()
let associations = try! decoder.decode(AssociationsFile.self, from: yaml)

print(associations)
//print(associations)

let fileList = CommandLine.arguments[1...]
let todos = fileList.compactMap { filePath -> String? in
let changedFile = try! File(path: filePath)

if
let parent = changedFile.parent,
let downsteamYML = try? parent.file(named: "downstream.yml").read(),
let associationsFile = try? decoder.decode(AssociationsFile.self, from: downsteamYML)
{
let fileName = changedFile.path(relativeTo: parent)
return associationsFile.associations[fileName]
}

return nil
}

print(todos)

0 comments on commit bfe1d25

Please sign in to comment.