Skip to content

Commit

Permalink
Vendor NodePackage wrapper
Browse files Browse the repository at this point in the history
...and deprecate it upstream
  • Loading branch information
fwcd committed Sep 19, 2024
1 parent b9f6864 commit 42874b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/D2Commands/Math/LatexRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class LatexRenderer {

private func renderPNG(from formula: String, color: String, scale: Double) async throws -> Data {
log.debug("Invoking latex-renderer")
return try await node.start(withArgs: [formula, "--color", color, "--scale", String(scale)]).get()
return try await node.start(withArgs: [formula, "--color", color, "--scale", String(scale)])
}
}
17 changes: 17 additions & 0 deletions Sources/D2Commands/NodePackage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation
import Utils

/// A wrapper around an executable node package that is located in the `Node`
/// folder of this repository.
public struct NodePackage {
private let directoryURL: URL

public init(name: String) {
directoryURL = URL(fileURLWithPath: "Node/\(name)")
}

/// Invokes `npm start` with the given arguments.
public func start(withArgs args: [String]) async throws -> Data {
try await Shell().output(for: "npm", in: directoryURL, args: ["run", "--silent", "start", "--"] + args).get()
}
}

0 comments on commit 42874b6

Please sign in to comment.