@@ -53,7 +53,7 @@ public struct OutputLoggingSettings: Sendable {
53
53
}
54
54
}
55
55
56
- public extension ProcessExecutor {
56
+ extension ProcessExecutor {
57
57
/// Run child process, discarding all its output.
58
58
///
59
59
/// - note: The `environment` defaults to the empty environment.
@@ -69,7 +69,7 @@ public extension ProcessExecutor {
69
69
/// don't want to
70
70
/// provide input.
71
71
/// - logger: Where to log diagnostic messages to (default to no where)
72
- static func run< StandardInput: AsyncSequence & Sendable > (
72
+ public static func run< StandardInput: AsyncSequence & Sendable > (
73
73
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
74
74
executable: String ,
75
75
_ arguments: [ String ] ,
@@ -106,7 +106,7 @@ public extension ProcessExecutor {
106
106
/// provide input.
107
107
/// - logger: Where to log diagnostic and output messages to
108
108
/// - logConfiguration: How to log the output lines
109
- static func runLogOutput< StandardInput: AsyncSequence & Sendable > (
109
+ public static func runLogOutput< StandardInput: AsyncSequence & Sendable > (
110
110
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
111
111
executable: String ,
112
112
_ arguments: [ String ] ,
@@ -128,7 +128,9 @@ public extension ProcessExecutor {
128
128
return try await withThrowingTaskGroup ( of: ProcessExitReason ? . self) { group in
129
129
group. addTask {
130
130
for try await (stream, line) in await merge (
131
- exe. standardOutput. splitIntoLines ( ) . strings. map { ( ProcessOutputStream . standardOutput, $0) } ,
131
+ exe. standardOutput. splitIntoLines ( ) . strings. map {
132
+ ( ProcessOutputStream . standardOutput, $0)
133
+ } ,
132
134
exe. standardError. splitIntoLines ( ) . strings. map { ( ProcessOutputStream . standardError, $0) }
133
135
) {
134
136
logger. log (
@@ -171,12 +173,12 @@ public extension ProcessExecutor {
171
173
/// - splitOutputIntoLines: Whether to call the closure with full lines (`true`) or arbitrary chunks of output
172
174
/// (`false`)
173
175
/// - logger: Where to log diagnostic and output messages to
174
- static func runProcessingOutput< StandardInput: AsyncSequence & Sendable > (
176
+ public static func runProcessingOutput< StandardInput: AsyncSequence & Sendable > (
175
177
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
176
178
executable: String ,
177
179
_ arguments: [ String ] ,
178
180
standardInput: StandardInput ,
179
- outputProcessor: @escaping @Sendable ( ProcessOutputStream, ByteBuffer) async throws -> ( ) ,
181
+ outputProcessor: @escaping @Sendable ( ProcessOutputStream, ByteBuffer) async throws -> Void ,
180
182
splitOutputIntoLines: Bool = false ,
181
183
environment: [ String : String ] = [ : ] ,
182
184
logger: Logger = ProcessExecutor . disableLogging
@@ -225,11 +227,11 @@ public extension ProcessExecutor {
225
227
}
226
228
}
227
229
228
- struct TooMuchProcessOutputError : Error , Sendable & Hashable {
230
+ public struct TooMuchProcessOutputError : Error , Sendable & Hashable {
229
231
public var stream : ProcessOutputStream
230
232
}
231
233
232
- struct ProcessExitReasonAndOutput : Sendable & Hashable {
234
+ public struct ProcessExitReasonAndOutput : Sendable & Hashable {
233
235
public var exitReason : ProcessExitReason
234
236
public var standardOutput : ByteBuffer ?
235
237
public var standardError : ByteBuffer ?
@@ -260,7 +262,7 @@ public extension ProcessExecutor {
260
262
/// - collectStandardError: If `true`, collect all of the child process' standard error into memory, discard if
261
263
/// `false`
262
264
/// - logger: Where to log diagnostic and output messages to
263
- static func runCollectingOutput< StandardInput: AsyncSequence & Sendable > (
265
+ public static func runCollectingOutput< StandardInput: AsyncSequence & Sendable > (
264
266
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
265
267
executable: String ,
266
268
_ arguments: [ String ] ,
@@ -287,7 +289,9 @@ public extension ProcessExecutor {
287
289
if collectStandardOutput {
288
290
var output : ByteBuffer ? = nil
289
291
for try await chunk in await exe. standardOutput {
290
- guard ( output? . readableBytes ?? 0 ) + chunk. readableBytes <= perStreamCollectionLimitBytes else {
292
+ guard
293
+ ( output? . readableBytes ?? 0 ) + chunk. readableBytes <= perStreamCollectionLimitBytes
294
+ else {
291
295
throw TooMuchProcessOutputError ( stream: . standardOutput)
292
296
}
293
297
output. setOrWriteImmutableBuffer ( chunk)
@@ -302,7 +306,9 @@ public extension ProcessExecutor {
302
306
if collectStandardError {
303
307
var output : ByteBuffer ? = nil
304
308
for try await chunk in await exe. standardError {
305
- guard ( output? . readableBytes ?? 0 ) + chunk. readableBytes <= perStreamCollectionLimitBytes else {
309
+ guard
310
+ ( output? . readableBytes ?? 0 ) + chunk. readableBytes <= perStreamCollectionLimitBytes
311
+ else {
306
312
throw TooMuchProcessOutputError ( stream: . standardError)
307
313
}
308
314
output. setOrWriteImmutableBuffer ( chunk)
@@ -317,7 +323,8 @@ public extension ProcessExecutor {
317
323
try await . exitReason( exe. run ( ) )
318
324
}
319
325
320
- var allInfo = ProcessExitReasonAndOutput ( exitReason: . exit( - 1 ) , standardOutput: nil , standardError: nil )
326
+ var allInfo = ProcessExitReasonAndOutput (
327
+ exitReason: . exit( - 1 ) , standardOutput: nil , standardError: nil )
321
328
while let next = try await group. next ( ) {
322
329
switch next {
323
330
case let . exitReason( exitReason) :
@@ -333,7 +340,7 @@ public extension ProcessExecutor {
333
340
}
334
341
}
335
342
336
- public extension ProcessExecutor {
343
+ extension ProcessExecutor {
337
344
/// Run child process, discarding all its output.
338
345
///
339
346
/// - note: The `environment` defaults to the empty environment.
@@ -346,7 +353,7 @@ public extension ProcessExecutor {
346
353
/// If you want to inherit the calling process' environment into the child, specify
347
354
/// `ProcessInfo.processInfo.environment`
348
355
/// - logger: Where to log diagnostic messages to (default to no where)
349
- static func run(
356
+ public static func run(
350
357
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
351
358
executable: String,
352
359
_ arguments: [ String] ,
@@ -376,7 +383,7 @@ public extension ProcessExecutor {
376
383
/// `ProcessInfo.processInfo.environment`
377
384
/// - logger: Where to log diagnostic and output messages to
378
385
/// - logConfiguration: How to log the output lines
379
- static func runLogOutput(
386
+ public static func runLogOutput(
380
387
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
381
388
executable: String ,
382
389
_ arguments: [ String ] ,
@@ -410,11 +417,11 @@ public extension ProcessExecutor {
410
417
/// - splitOutputIntoLines: Whether to call the closure with full lines (`true`) or arbitrary chunks of output
411
418
/// (`false`)
412
419
/// - logger: Where to log diagnostic and output messages to
413
- static func runProcessingOutput(
420
+ public static func runProcessingOutput(
414
421
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
415
422
executable: String ,
416
423
_ arguments: [ String ] ,
417
- outputProcessor: @escaping @Sendable ( ProcessOutputStream, ByteBuffer) async throws -> ( ) ,
424
+ outputProcessor: @escaping @Sendable ( ProcessOutputStream, ByteBuffer) async throws -> Void ,
418
425
splitOutputIntoLines: Bool = false ,
419
426
environment: [ String : String ] = [ : ] ,
420
427
logger: Logger = ProcessExecutor . disableLogging
@@ -447,7 +454,7 @@ public extension ProcessExecutor {
447
454
/// - collectStandardError: If `true`, collect all of the child process' standard error into memory, discard if
448
455
/// `false`
449
456
/// - logger: Where to log diagnostic and output messages to
450
- static func runCollectingOutput(
457
+ public static func runCollectingOutput(
451
458
group: EventLoopGroup = ProcessExecutor . defaultEventLoopGroup,
452
459
executable: String ,
453
460
_ arguments: [ String ] ,
0 commit comments