Skip to content

Commit 0ffbafb

Browse files
author
Oren Novotny
authored
Merge pull request #133 from dotnet/client-fixes
Client fixes
2 parents 497d23c + dfc1346 commit 0ffbafb

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/SignClient/SignCommand.cs

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.IO;
45
using System.Linq;
56
using System.Net;
@@ -90,7 +91,9 @@ CommandOption maxConcurrency
9091
List<FileInfo> inputFiles;
9192
// If we're going to glob, we can't be fully rooted currently (fix me later)
9293

93-
if(inputFile.Value().Contains('*'))
94+
var isGlob = inputFile.Value().Contains('*');
95+
96+
if (isGlob)
9497
{
9598
if(Path.IsPathRooted(inputFile.Value()))
9699
{
@@ -169,14 +172,25 @@ CommandOption maxConcurrency
169172
{
170173
FileInfo output;
171174

175+
var sw = Stopwatch.StartNew();
176+
172177
// Special case if there's only one input file and the output has a value, treat it as a file
173178
if(inputFiles.Count == 1 && outputFile.HasValue())
174-
{
175-
output = new FileInfo(ExpandFilePath(outputFile.Value()));
179+
{
180+
// See if it has a file extension and if not, treat as a directory and use the input file name
181+
var outFileValue = outputFile.Value();
182+
if(Path.HasExtension(outFileValue))
183+
{
184+
output = new FileInfo(ExpandFilePath(outputFile.Value()));
185+
}
186+
else
187+
{
188+
output = new FileInfo(Path.Combine(ExpandFilePath(outFileValue), inputFiles[0].Name));
189+
}
176190
}
177191
else
178192
{
179-
// if the output is speciied, treat it as a directory, if not, overwrite the current file
193+
// if the output is specified, treat it as a directory, if not, overwrite the current file
180194
if(!outputFile.HasValue())
181195
{
182196
output = new FileInfo(input.FullName);
@@ -226,7 +240,7 @@ CommandOption maxConcurrency
226240
using var fs = new FileStream(output.FullName, FileMode.Create);
227241
str.CopyTo(fs);
228242

229-
signCommandLineApplication.Out.WriteLine($"Successfully signed '{input.FullName}'");
243+
signCommandLineApplication.Out.WriteLine($"Successfully signed '{output.FullName}' in {sw.ElapsedMilliseconds} ms");
230244
});
231245

232246

0 commit comments

Comments
 (0)