Skip to content

Commit dfc1346

Browse files
author
Oren Novotny
committed
enable use of a directory output for single inputs
1 parent 3f34088 commit dfc1346

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/SignClient/SignCommand.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ CommandOption maxConcurrency
9191
List<FileInfo> inputFiles;
9292
// If we're going to glob, we can't be fully rooted currently (fix me later)
9393

94-
if(inputFile.Value().Contains('*'))
94+
var isGlob = inputFile.Value().Contains('*');
95+
96+
if (isGlob)
9597
{
9698
if(Path.IsPathRooted(inputFile.Value()))
9799
{
@@ -174,12 +176,21 @@ CommandOption maxConcurrency
174176

175177
// Special case if there's only one input file and the output has a value, treat it as a file
176178
if(inputFiles.Count == 1 && outputFile.HasValue())
177-
{
178-
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+
}
179190
}
180191
else
181192
{
182-
// 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
183194
if(!outputFile.HasValue())
184195
{
185196
output = new FileInfo(input.FullName);

0 commit comments

Comments
 (0)