Skip to content

Commit

Permalink
enable use of a directory output for single inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Novotny committed Oct 31, 2019
1 parent 3f34088 commit dfc1346
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/SignClient/SignCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,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 @@ -174,12 +176,21 @@ CommandOption maxConcurrency

// 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

0 comments on commit dfc1346

Please sign in to comment.