From 869d6dbef825183454ecdd803708e7f448a1011f Mon Sep 17 00:00:00 2001 From: "bela.vandervoort" Date: Tue, 21 Nov 2023 19:28:47 -0600 Subject: [PATCH] Fix this for piping multiple files, which does contain proper filePath --- Src/CSharpier.Cli/CommandLineFormatter.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Src/CSharpier.Cli/CommandLineFormatter.cs b/Src/CSharpier.Cli/CommandLineFormatter.cs index 469f7a04c..cd74f9e1d 100644 --- a/Src/CSharpier.Cli/CommandLineFormatter.cs +++ b/Src/CSharpier.Cli/CommandLineFormatter.cs @@ -24,11 +24,14 @@ CancellationToken cancellationToken if (commandLineOptions.StandardInFileContents != null) { - // currently when piping stdin, this will always be a directory - var directoryPath = commandLineOptions.DirectoryOrFilePaths[0]; - // but we need a filename to correctly find config files - // #288 should be done once we support csproj/xml, and possibly be required - var filePath = Path.Combine(directoryPath, "StdIn.cs"); + var directoryOrFilePath = commandLineOptions.DirectoryOrFilePaths[0]; + var directoryPath = fileSystem.Directory.Exists(directoryOrFilePath) + ? directoryOrFilePath + : fileSystem.Path.GetDirectoryName(directoryOrFilePath); + var filePath = + directoryOrFilePath != directoryPath + ? directoryOrFilePath + : Path.Combine(directoryPath, "StdIn.cs"); var fileToFormatInfo = FileToFormatInfo.Create( filePath,