Skip to content

Commit 5c3e6ac

Browse files
authored
save Package.resolved with a trailing newline (#3822)
motivation: we lost the trailing newline when moving to COdable based encoder changes: add trailing newline in POSIXy systems rdar://83646952
1 parent 77f7ac7 commit 5c3e6ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/PackageGraph/PinsStore.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,20 @@ fileprivate struct PinsStorage {
161161
return
162162
}
163163

164-
let data: Data
164+
var data: Data
165165
if toolsVersion >= .v5_6 {
166166
let container = try V2(pins: pins, mirrors: mirrors)
167167
data = try self.encoder.encode(container)
168168
} else {
169169
let container = try V1(pins: pins, mirrors: mirrors)
170170
data = try self.encoder.encode(container)
171171
}
172+
#if !os(Windows)
173+
// rdar://83646952: add newline for POSIXy systems
174+
if data.last != 0x0a {
175+
data.append(0x0a)
176+
}
177+
#endif
172178
try self.fileSystem.writeFileContents(self.path, data: data)
173179
}
174180
}

0 commit comments

Comments
 (0)