Skip to content

Commit 07fea99

Browse files
committed
Revert "Remove swift-log dependency"
This reverts commit 826125c.
1 parent 5077225 commit 07fea99

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Package.resolved

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ let package = Package(
1515
.library(name: "ShellOut", targets: ["ShellOut"])
1616
],
1717
dependencies: [
18-
.package(url: "https://github.com/SwiftPackageIndex/ShellQuote", from: "1.0.2")
18+
.package(url: "https://github.com/SwiftPackageIndex/ShellQuote", from: "1.0.2"),
19+
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
1920
],
2021
targets: [
2122
.target(
2223
name: "ShellOut",
2324
dependencies: [
24-
.product(name: "ShellQuote", package: "ShellQuote")
25+
.product(name: "ShellQuote", package: "ShellQuote"),
26+
.product(name: "Logging", package: "swift-log"),
2527
],
2628
path: "Sources"
2729
),

Sources/ShellOut.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import Foundation
88
import Dispatch
9+
import Logging
910

1011
// MARK: - API
1112

@@ -33,6 +34,7 @@ import Dispatch
3334
arguments: [Argument] = [],
3435
at path: String = ".",
3536
process: Process = .init(),
37+
logger: Logger? = nil,
3638
outputHandle: FileHandle? = nil,
3739
errorHandle: FileHandle? = nil,
3840
environment: [String : String]? = nil,
@@ -42,6 +44,7 @@ import Dispatch
4244

4345
return try process.launchBash(
4446
with: command,
47+
logger: logger,
4548
outputHandle: outputHandle,
4649
errorHandle: errorHandle,
4750
environment: environment,
@@ -90,6 +93,7 @@ import Dispatch
9093
to command: ShellOutCommand,
9194
at path: String = ".",
9295
process: Process = .init(),
96+
logger: Logger? = nil,
9397
outputHandle: FileHandle? = nil,
9498
errorHandle: FileHandle? = nil,
9599
environment: [String : String]? = nil,
@@ -100,6 +104,7 @@ import Dispatch
100104
arguments: command.arguments,
101105
at: path,
102106
process: process,
107+
logger: logger,
103108
outputHandle: outputHandle,
104109
errorHandle: errorHandle,
105110
environment: environment,
@@ -435,6 +440,7 @@ extension ShellOutCommand {
435440
private extension Process {
436441
@discardableResult func launchBash(
437442
with command: String,
443+
logger: Logger? = nil,
438444
outputHandle: FileHandle? = nil,
439445
errorHandle: FileHandle? = nil,
440446
environment: [String : String]? = nil,
@@ -493,7 +499,9 @@ private extension Process {
493499
try self.run()
494500
self.waitUntilExit()
495501

496-
_ = outputGroup.wait(timeout: .now() + eofTimeout)
502+
if outputGroup.wait(timeout: .now() + eofTimeout) == .timedOut {
503+
logger?.warning("ShellOut.launchBash: Timed out waiting for EOF! (command: \(command))")
504+
}
497505

498506
// We know as of this point that either all blocks have been submitted to the
499507
// queue already, or we've reached our wait timeout.

0 commit comments

Comments
 (0)