Fix root file link override

This commit is contained in:
2024-03-11 17:05:29 +01:00
parent 2d4fc2c345
commit 4b40aa64b9
2 changed files with 12 additions and 5 deletions

4
.vscode/launch.json vendored
View File

@@ -10,8 +10,8 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Alma/bin/Debug/net7.0/Alma.dll",
"args": [],
"program": "${workspaceFolder}/src/Alma/bin/Debug/net8.0/Alma.dll",
"args": ["link", "dotconfig", "git", "-d"],
"cwd": "${workspaceFolder}/src/Alma",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",

View File

@@ -111,13 +111,13 @@ public class LinkCommand : RepositoryModuleCommandBase
{
var excludePath = Path.Combine(moduleDirectory, Path.Combine(itemToExclude.Split('/')));
itemsToLink.RemoveAll(
i => i.SourcePath == excludePath
i => i.SourcePath == excludePath
|| i.SourcePath.StartsWith(excludePath + Path.DirectorySeparatorChar)
);
}
}
if(moduleConfiguration?.ExcludeReadme ?? false)
if (moduleConfiguration?.ExcludeReadme ?? false)
{
foreach (var readmeFile in Enum.GetValues<ReadmeFiles>())
{
@@ -201,7 +201,14 @@ public class LinkCommand : RepositoryModuleCommandBase
var filesToLink = new List<ItemToLink>();
foreach (var file in currentDirectory.GetFiles())
{
filesToLink.Add(new ItemToLink(Path.Combine(currentDirectory.FullName, file.Name), Path.Combine(currentTargetDirectory.FullName, file.Name)));
if (moduleConfiguration?.Links?.ContainsKey(file.Name) ?? false)
{
filesToLink.Add(new ItemToLink(file.FullName, _pathHelperService.ResolvePath(moduleConfiguration.Links[file.Name], targetDirectory.FullName)));
}
else
{
filesToLink.Add(new ItemToLink(file.FullName, Path.Combine(currentTargetDirectory.FullName, file.Name)));
}
}
var subDirLinksToAdd = Enumerable.Empty<ItemToLink>();