From d660d0ebb4dcc638c269c04b86117a88b7f135ce Mon Sep 17 00:00:00 2001 From: George Lyon Date: Fri, 10 Dec 2021 15:37:05 -0800 Subject: [PATCH] Add pipe variant where destination is PipableCommand (#7) --- Sources/Script/Pipe.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/Script/Pipe.swift b/Sources/Script/Pipe.swift index ca25c9b..c6d879b 100644 --- a/Sources/Script/Pipe.swift +++ b/Sources/Script/Pipe.swift @@ -25,6 +25,17 @@ public func | ( } } +/** + Special form of `pipe` which allows piping to a builtin like `map` + */ +public func pipe( + _ outputChannel: Shell.OutputChannel, + of source: () async throws -> SourceOutcome, + to destination: Shell.PipableCommand +) async throws -> (source: SourceOutcome, destination: DestinationOutcome) { + try await pipe(outputChannel, of: source, to: { try await destination.body() }) +} + public func pipe( _ outputChannel: Shell.OutputChannel, of source: () async throws -> SourceOutcome,