Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: "5.10.1"
- uses: actions/checkout@v4
- run: swift package resolve
- run: swift build
- uses: vapor/swiftly-action@v0.2
with:
toolchain: "6.3"
- run: swift test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ xcuserdata/
DerivedData/
.swiftpm
.netrc
.vscode
42 changes: 8 additions & 34 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 6.0

import PackageDescription

Expand All @@ -9,7 +9,7 @@ let package = Package(
.library(name: "TypeScriptAST", targets: ["TypeScriptAST"])
],
dependencies: [
.package(url: "https://github.com/omochi/CodegenKit.git", from: "2.0.0")
.package(url: "https://github.com/omochi/CodegenKit.git", from: "2.1.1")
],
targets: [
.executableTarget(
Expand Down
6 changes: 3 additions & 3 deletions Plugins/CodegenPlugin/CodegenPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ struct CodegenPlugin: CommandPlugin {
func performCommand(context: PluginContext, arguments: [String]) async throws {
let codegen = try context.tool(named: "codegen")

let sourcesDir = context.package.directory.appending(subpath: "Sources")
let sourcesDir = context.package.directoryURL.appending(path: "Sources")

let process = EasyProcess(
path: URL(fileURLWithPath: codegen.path.string),
args: [sourcesDir.string]
path: codegen.url,
args: [sourcesDir.path(percentEncoded: false)]
)
try process.run()
}
Expand Down
18 changes: 9 additions & 9 deletions Plugins/CodegenPlugin/EasyProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ struct EasyProcess {
init(
path: URL,
args: [String],
outSink: ((Data) -> Void)? = nil,
errorSink: ((Data) -> Void)? = nil
outSink: (@Sendable (Data) -> Void)? = nil,
errorSink: (@Sendable (Data) -> Void)? = nil
) {
self.path = path
self.args = args
Expand All @@ -15,20 +15,20 @@ struct EasyProcess {

var path: URL
var args: [String]
var outSink: (Data) -> Void
var errorSink: (Data) -> Void
var outSink: @Sendable (Data) -> Void
var errorSink: @Sendable (Data) -> Void

static func makeFileHandleSink(fileHandle: FileHandle) -> (Data) -> Void {
static func makeFileHandleSink(fileHandle: FileHandle) -> @Sendable (Data) -> Void {
return { (data) in
try? fileHandle.write(contentsOf: data)
}
}

static var defaultOutSink: (Data) -> Void {
static var defaultOutSink: @Sendable (Data) -> Void {
makeFileHandleSink(fileHandle: .standardOutput)
}

static var defaultErrorSink: (Data) -> Void {
static var defaultErrorSink: @Sendable (Data) -> Void {
makeFileHandleSink(fileHandle: .standardError)
}

Expand All @@ -43,7 +43,7 @@ struct EasyProcess {
let outPipe = Pipe()
p.standardOutput = outPipe

outPipe.fileHandleForReading.readabilityHandler = { (h) in
outPipe.fileHandleForReading.readabilityHandler = { [outSink] (h) in
queue.sync {
let data = h.availableData
if !data.isEmpty {
Expand All @@ -55,7 +55,7 @@ struct EasyProcess {
let errPipe = Pipe()
p.standardError = errPipe

errPipe.fileHandleForReading.readabilityHandler = { (h) in
errPipe.fileHandleForReading.readabilityHandler = { [errorSink] (h) in
queue.sync {
let data = h.availableData
if !data.isEmpty {
Expand Down
2 changes: 1 addition & 1 deletion Tests/TypeScriptASTTests/TestCaseBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TestCaseBase: XCTestCase {
func assertPrint(
_ node: any ASTNode,
_ expected: String,
file: StaticString = #file,
file: StaticString = #filePath,
line: UInt = #line
) {
XCTAssertEqual(node.print(), expected, file: file, line: line)
Expand Down
Loading