Skip to content

Commit c658a00

Browse files
authored
Merge pull request #794 from shawnhyam/assume-filename
Support assume-filename option to find the configuration file when reading from stdin.
2 parents 3d79237 + 16c2c28 commit c658a00

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/swift-format/Frontend/Frontend.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,19 @@ class Frontend {
117117

118118
/// Processes source content from standard input.
119119
private func processStandardInput() {
120+
let assumedUrl = lintFormatOptions.assumeFilename.map(URL.init(fileURLWithPath:))
121+
120122
guard let configuration = configuration(
121123
fromPathOrString: lintFormatOptions.configuration,
122-
orInferredFromSwiftFileAt: nil)
124+
orInferredFromSwiftFileAt: assumedUrl)
123125
else {
124126
// Already diagnosed in the called method.
125127
return
126128
}
127129

128130
let fileToProcess = FileToProcess(
129131
fileHandle: FileHandle.standardInput,
130-
url: URL(fileURLWithPath: lintFormatOptions.assumeFilename ?? "<stdin>"),
132+
url: assumedUrl ?? URL(fileURLWithPath: "<stdin>"),
131133
configuration: configuration,
132134
selection: Selection(offsetRanges: lintFormatOptions.offsets))
133135
processFile(fileToProcess)

0 commit comments

Comments
 (0)