Skip to content
Open
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: 4 additions & 4 deletions Sources/SwiftyESBuild/Downloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ class Downloader: Downloading {
switch version {
case let .fixed(rawVersion):
if rawVersion.starts(with: "v") {
return rawVersion
} else {
/**
Releases on GitHub are prefixed with "v" so we need to include it.
Versions on the npm Registry are not prefixed with "v" so we need to remove it.
*/
return "v\(rawVersion)"
return String(rawVersion.dropFirst())
} else {
return rawVersion
}
case .latest: return npmPackage.distTags.latest
}
Expand Down
20 changes: 20 additions & 0 deletions Tests/SwiftyESBuildTests/DownloaderTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@testable import SwiftyESBuild
import TSCBasic
import TSCUtility
import XCTest

final class DownloaderTests: XCTestCase {
func testDownloadFixedVersion() async throws {
try await withTemporaryDirectory(removeTreeOnDeinit: true) { tmpDir in
// Given
let subject = Downloader()
let version = "0.19.11"

// When
let path = try await subject.download(version: .fixed(version), directory: tmpDir)

// Then
XCTAssertTrue(path.pathString.hasSuffix("/\(version)/esbuild"))
}
}
}