Skip to content

Commit ce2905b

Browse files
committed
target known locations first before initiating a folder scan
1 parent b72199b commit ce2905b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Elastic.Markdown/BuildContext.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ public BuildContext(IFileSystem readFileSystem, IFileSystem writeFileSystem, str
6464

6565
private (IDirectoryInfo, IFileInfo) FindDocsFolderFromRoot(IDirectoryInfo rootPath)
6666
{
67-
var configurationPath = ReadFileSystem.FileInfo.New(Path.Combine(rootPath.FullName, "docset.yml"));
68-
if (rootPath.Exists &&
69-
ReadFileSystem.File.Exists(Path.Combine(rootPath.FullName, "docset.yml")))
70-
return (rootPath, configurationPath);
71-
72-
configurationPath = ReadFileSystem.FileInfo.New(Path.Combine(rootPath.FullName, "_docset.yml"));
73-
if (rootPath.Exists &&
74-
ReadFileSystem.File.Exists(Path.Combine(rootPath.FullName, "_docset.yml")))
75-
return (rootPath, configurationPath);
67+
string[] files = ["docset.yml", "_docset.yml"];
68+
string[] knownFolders = [rootPath.FullName, Path.Combine(rootPath.FullName, "docs")];
69+
var mostLikelyTargets =
70+
from file in files
71+
from folder in knownFolders
72+
select Path.Combine(folder, file);
73+
74+
var knownConfigPath = mostLikelyTargets.FirstOrDefault(ReadFileSystem.File.Exists);
75+
var configurationPath = knownConfigPath is null ? null : ReadFileSystem.FileInfo.New(knownConfigPath);
76+
if (configurationPath is not null)
77+
return (configurationPath.Directory!, configurationPath);
7678

7779
configurationPath = rootPath
7880
.EnumerateFiles("*docset.yml", SearchOption.AllDirectories)

0 commit comments

Comments
 (0)