mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
3fd1573c57
* ✨ (spm) add build tool plugin definition for swiftlint * 📝 (changelog) add changelog item for the plugin * 🐛 (cache) define cache path explicitly to avoid issues during build without issues * 🎨 minor code cleanup * 📝 document usage with Xcode as well as Swift packages
44 lines
1.1 KiB
Swift
44 lines
1.1 KiB
Swift
import Foundation
|
|
import PackagePlugin
|
|
|
|
@main
|
|
struct SwiftLintPlugin: BuildToolPlugin {
|
|
func createBuildCommands(
|
|
context: PackagePlugin.PluginContext,
|
|
target: PackagePlugin.Target
|
|
) async throws -> [PackagePlugin.Command] {
|
|
[
|
|
.buildCommand(
|
|
displayName: "SwiftLint",
|
|
executable: try context.tool(named: "swiftlint").path,
|
|
arguments: [
|
|
"lint",
|
|
"--cache-path", "\(context.pluginWorkDirectory)"
|
|
]
|
|
)
|
|
]
|
|
}
|
|
}
|
|
|
|
#if canImport(XcodeProjectPlugin)
|
|
import XcodeProjectPlugin
|
|
|
|
extension SwiftLintPlugin: XcodeBuildToolPlugin {
|
|
func createBuildCommands(
|
|
context: XcodePluginContext,
|
|
target: XcodeTarget
|
|
) throws -> [Command] {
|
|
[
|
|
.buildCommand(
|
|
displayName: "SwiftLint",
|
|
executable: try context.tool(named: "swiftlint").path,
|
|
arguments: [
|
|
"lint",
|
|
"--cache-path", "\(context.pluginWorkDirectory)"
|
|
]
|
|
)
|
|
]
|
|
}
|
|
}
|
|
#endif
|