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
|