|
6 | 6 |
|
7 | 7 | namespace GitVersion; |
8 | 8 |
|
9 | | -internal class ArgumentParser(IEnvironment environment, ICurrentBuildAgent buildAgent, IConsole console, IGlobbingResolver globbingResolver) |
| 9 | +internal class ArgumentParser(IEnvironment environment, |
| 10 | + IFileSystem fileSystem, |
| 11 | + ICurrentBuildAgent buildAgent, |
| 12 | + IConsole console, |
| 13 | + IGlobbingResolver globbingResolver) |
10 | 14 | : IArgumentParser |
11 | 15 | { |
12 | 16 | private readonly IEnvironment environment = environment.NotNull(); |
| 17 | + private readonly IFileSystem fileSystem = fileSystem.NotNull(); |
13 | 18 | private readonly ICurrentBuildAgent buildAgent = buildAgent.NotNull(); |
14 | 19 | private readonly IConsole console = console.NotNull(); |
15 | 20 | private readonly IGlobbingResolver globbingResolver = globbingResolver.NotNull(); |
@@ -97,19 +102,19 @@ public Arguments ParseArguments(string[] commandLineArguments) |
97 | 102 | return arguments; |
98 | 103 | } |
99 | 104 |
|
100 | | - private static void ValidateConfigurationFile(Arguments arguments) |
| 105 | + private void ValidateConfigurationFile(Arguments arguments) |
101 | 106 | { |
102 | 107 | if (arguments.ConfigurationFile.IsNullOrWhiteSpace()) return; |
103 | 108 |
|
104 | 109 | if (Path.IsPathRooted(arguments.ConfigurationFile)) |
105 | 110 | { |
106 | | - if (!File.Exists(arguments.ConfigurationFile)) throw new WarningException($"Could not find config file at '{arguments.ConfigurationFile}'"); |
| 111 | + if (!this.fileSystem.Exists(arguments.ConfigurationFile)) throw new WarningException($"Could not find config file at '{arguments.ConfigurationFile}'"); |
107 | 112 | arguments.ConfigurationFile = Path.GetFullPath(arguments.ConfigurationFile); |
108 | 113 | } |
109 | 114 | else |
110 | 115 | { |
111 | 116 | var configFilePath = Path.GetFullPath(PathHelper.Combine(arguments.TargetPath, arguments.ConfigurationFile)); |
112 | | - if (!File.Exists(configFilePath)) throw new WarningException($"Could not find config file at '{configFilePath}'"); |
| 117 | + if (!this.fileSystem.Exists(configFilePath)) throw new WarningException($"Could not find config file at '{configFilePath}'"); |
113 | 118 | arguments.ConfigurationFile = configFilePath; |
114 | 119 | } |
115 | 120 | } |
@@ -161,7 +166,7 @@ private void ParseTargetPath(Arguments arguments, string? name, IReadOnlyList<st |
161 | 166 | { |
162 | 167 | EnsureArgumentValueCount(values); |
163 | 168 | arguments.TargetPath = value; |
164 | | - if (!Directory.Exists(value)) |
| 169 | + if (!this.fileSystem.DirectoryExists(value)) |
165 | 170 | { |
166 | 171 | this.console.WriteLine($"The working directory '{value}' does not exist."); |
167 | 172 | } |
|
0 commit comments