Skip to content

Commit 116adc5

Browse files
authored
Merge pull request #16 from p-x9/feature/throw-script-error
If scrips terminate with an error, raise a build warning
2 parents 83f03f9 + 95a0898 commit 116adc5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/run-script/main.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ extension RunScript {
8585
extension RunScript {
8686
func run(_ script: Script) throws {
8787
let process = Process()
88+
let errorPipe = Pipe()
8889

8990
process.launchPath = script.launchPath ?? "/bin/sh"
91+
process.standardError = errorPipe
9092

9193
if let path = script.path {
9294
process.arguments = [path]
@@ -96,8 +98,12 @@ extension RunScript {
9698
process.arguments = ["-c", script]
9799
}
98100

99-
process.launch()
100-
process.waitUntilExit()
101+
try process.run()
102+
103+
let errorData = errorPipe.fileHandleForReading.readDataToEndOfFile()
104+
if let error = String(data: errorData, encoding: .utf8) {
105+
log("warning: [RunScriptPlugin] " + error)
106+
}
101107
}
102108
}
103109

0 commit comments

Comments
 (0)