Skip to content

Commit 199b8b9

Browse files
committed
In shellOut() itself, use the provided logger (if any) to provide a logging handler
1 parent 42e0bea commit 199b8b9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/ShellOut.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,14 @@ private extension TSCBasic.Process {
102102
environment: [String : String]? = nil,
103103
at: String? = nil
104104
) async throws -> (stdout: String, stderr: String) {
105-
let process = try Self.init(
105+
let actualCwd = try at.map { try .init(validating: $0) } ?? TSCBasic.localFileSystem.currentWorkingDirectory ?? .root
106+
let process = Self.init(
106107
arguments: [command] + arguments,
107108
environment: environment ?? ProcessEnv.vars,
108-
workingDirectory: at.map { try .init(validating: $0) } ?? TSCBasic.localFileSystem.currentWorkingDirectory ?? .root,
109+
workingDirectory: actualCwd,
109110
outputRedirection: .collect(redirectStderr: false),
110111
startNewProcessGroup: false,
111-
loggingHandler: nil
112+
loggingHandler: logger.map { logger in { logger.debug("\($0)", metadata: ["cwd": .string(actualCwd.pathString)]) } }
112113
)
113114

114115
try process.launch()

0 commit comments

Comments
 (0)