diff --git a/Package.swift b/Package.swift index 8cbabbf..abbf6c5 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.5 +// swift-tools-version:5.8 import PackageDescription let package = Package( diff --git a/Sources/wkhtmltopdf/Document+Generate.swift b/Sources/wkhtmltopdf/Document+Generate.swift index 611dc36..3ec4544 100644 --- a/Sources/wkhtmltopdf/Document+Generate.swift +++ b/Sources/wkhtmltopdf/Document+Generate.swift @@ -40,14 +40,15 @@ extension Document { // Call wkhtmltopdf and retrieve the result data let wk = Process() let stdout = Pipe() - wk.launchPath = self.launchPath + wk.executableURL = URL(fileURLWithPath: self.launchPath) wk.arguments = wkArgs wk.arguments?.append("-") // output to stdout wk.standardOutput = stdout - wk.launch() + try wk.run() let pdf = stdout.fileHandleForReading.readDataToEndOfFile() continuation.resume(returning: pdf) + try stdout.fileHandleForReading.close() }.flatMapErrorThrowing { err in continuation.resume(throwing: err) return diff --git a/Tests/wkhtmltopdfTests/wkhtmltopdfTests.swift b/Tests/wkhtmltopdfTests/wkhtmltopdfTests.swift index c43d611..f73c56c 100644 --- a/Tests/wkhtmltopdfTests/wkhtmltopdfTests.swift +++ b/Tests/wkhtmltopdfTests/wkhtmltopdfTests.swift @@ -28,7 +28,7 @@ class wkhtmltopdfTests: XCTestCase { let threadPool = NIOThreadPool(numberOfThreads: 1) threadPool.start() let data = try await document.generatePDF(on: threadPool, eventLoop: eventLoop) - try threadPool.syncShutdownGracefully() + try await threadPool.shutdownGracefully() // Cop-out test, just ensuring that the returned data is something XCTAssert(data.count > 50) // Visual test