Skip to content

Commit

Permalink
Merge pull request #133 from dotnet/client-fixes
Browse files Browse the repository at this point in the history
Client fixes
  • Loading branch information
Oren Novotny authored Oct 31, 2019
2 parents 497d23c + dfc1346 commit 0ffbafb
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/SignClient/SignCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -90,7 +91,9 @@ CommandOption maxConcurrency
List<FileInfo> inputFiles;
// If we're going to glob, we can't be fully rooted currently (fix me later)

if(inputFile.Value().Contains('*'))
var isGlob = inputFile.Value().Contains('*');

if (isGlob)
{
if(Path.IsPathRooted(inputFile.Value()))
{
Expand Down Expand Up @@ -169,14 +172,25 @@ CommandOption maxConcurrency
{
FileInfo output;
var sw = Stopwatch.StartNew();
// Special case if there's only one input file and the output has a value, treat it as a file
if(inputFiles.Count == 1 && outputFile.HasValue())
{
output = new FileInfo(ExpandFilePath(outputFile.Value()));
{
// See if it has a file extension and if not, treat as a directory and use the input file name
var outFileValue = outputFile.Value();
if(Path.HasExtension(outFileValue))
{
output = new FileInfo(ExpandFilePath(outputFile.Value()));
}
else
{
output = new FileInfo(Path.Combine(ExpandFilePath(outFileValue), inputFiles[0].Name));
}
}
else
{
// if the output is speciied, treat it as a directory, if not, overwrite the current file
// if the output is specified, treat it as a directory, if not, overwrite the current file
if(!outputFile.HasValue())
{
output = new FileInfo(input.FullName);
Expand Down Expand Up @@ -226,7 +240,7 @@ CommandOption maxConcurrency
using var fs = new FileStream(output.FullName, FileMode.Create);
str.CopyTo(fs);
signCommandLineApplication.Out.WriteLine($"Successfully signed '{input.FullName}'");
signCommandLineApplication.Out.WriteLine($"Successfully signed '{output.FullName}' in {sw.ElapsedMilliseconds} ms");
});


Expand Down

0 comments on commit 0ffbafb

Please sign in to comment.