Skip to content

Commit

Permalink
Fix this for piping multiple files, which does contain proper filePath
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Nov 22, 2023
1 parent 89adac4 commit 869d6db
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Src/CSharpier.Cli/CommandLineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 869d6db

Please sign in to comment.