From 4b40aa64b96597a7b152eef44ff4a2d01a4061a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= Date: Mon, 11 Mar 2024 17:05:29 +0100 Subject: [PATCH] Fix root file link override --- .vscode/launch.json | 4 ++-- src/Alma.App/Command/Link/LinkCommand.cs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b13839c..7add8f9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/src/Alma.App/Command/Link/LinkCommand.cs b/src/Alma.App/Command/Link/LinkCommand.cs index ae9145a..9200568 100644 --- a/src/Alma.App/Command/Link/LinkCommand.cs +++ b/src/Alma.App/Command/Link/LinkCommand.cs @@ -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()) { @@ -201,7 +201,14 @@ public class LinkCommand : RepositoryModuleCommandBase var filesToLink = new List(); 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();