@@ -33,12 +33,17 @@ extension Toolkit {
33
33
group. subGroups = subGroups
34
34
}
35
35
36
+ if let readmePath = pathForReadme ( from: directory) {
37
+ group. readme = readmePath
38
+ }
39
+
36
40
if values. isEmpty == false || subGroups. isEmpty == false {
37
41
parentGroups. append ( group)
38
42
}
39
43
}
40
44
41
45
let directoryFiles = onlyFiles ( at: path)
46
+
42
47
for file in directoryFiles where directoryFiles. isEmpty == false {
43
48
guard ignoreFilesInDir == false else {
44
49
continue
@@ -67,6 +72,27 @@ extension Toolkit {
67
72
return scriptCommands
68
73
}
69
74
75
+ func pathForReadme( from folderPath: AbsolutePath ) -> String ? {
76
+ let directoryFiles = onlyFiles ( at: folderPath)
77
+
78
+ for file in directoryFiles where directoryFiles. isEmpty == false {
79
+ guard file. basenameWithoutExt. lowercased ( ) == " readme " else {
80
+ continue
81
+ }
82
+
83
+ guard let fileContent = readContentFile ( from: file) , fileContent. count > 0 else {
84
+ continue
85
+ }
86
+
87
+ let pathCount = dataManager. extensionsPathString. count + 1
88
+ let readmePath = file. pathString. dropFirst ( pathCount)
89
+
90
+ return String ( readmePath)
91
+ }
92
+
93
+ return nil
94
+ }
95
+
70
96
func readContentFile( from path: AbsolutePath ) -> String ? {
71
97
guard let byteString = try ? fileSystem. readFileContents ( path) else {
72
98
return nil
@@ -80,7 +106,7 @@ extension Toolkit {
80
106
81
107
func extractGitDates( from filePath: AbsolutePath ) -> [ String ] ? {
82
108
do {
83
- let dates = try self . git. run (
109
+ let dates = try git. run (
84
110
" log " , " --format=%aI " , " --follow " , filePath. basename,
85
111
path: filePath
86
112
)
0 commit comments