File tree Expand file tree Collapse file tree 5 files changed +59
-9
lines changed
.swiftpm/xcode/xcshareddata/xcschemes
Plugins/SwiftFormatterPlugin
Sources/SwiftFormatterPluginDefaults Expand file tree Collapse file tree 5 files changed +59
-9
lines changed Original file line number Diff line number Diff line change 4848 ReferencedContainer = " container:" >
4949 </BuildableReference >
5050 </BuildActionEntry >
51+ <BuildActionEntry
52+ buildForTesting = " YES"
53+ buildForRunning = " YES"
54+ buildForProfiling = " YES"
55+ buildForArchiving = " YES"
56+ buildForAnalyzing = " YES" >
57+ <BuildableReference
58+ BuildableIdentifier = " primary"
59+ BlueprintIdentifier = " SwiftFormatterPluginDefaults"
60+ BuildableName = " SwiftFormatterPluginDefaults"
61+ BlueprintName = " SwiftFormatterPluginDefaults"
62+ ReferencedContainer = " container:" >
63+ </BuildableReference >
64+ </BuildActionEntry >
5165 </BuildActionEntries >
5266 </BuildAction >
5367 <TestAction
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ let package = Package(
1414 ] ,
1515
1616 products: [
17+ . library(
18+ name: " SwiftFormatterPluginDefaults " ,
19+ targets: [
20+ " SwiftFormatterPluginDefaults "
21+ ]
22+ ) ,
23+
1724 . plugin(
1825 name: " SwiftFormatterPlugin " ,
1926 targets: [
@@ -27,9 +34,17 @@ let package = Package(
2734 ] ,
2835
2936 targets: [
37+ . target(
38+ name: " SwiftFormatterPluginDefaults " ,
39+
40+ resources: [
41+ . copy( " Resources/default-config " )
42+ ]
43+ ) ,
44+
3045 . plugin(
3146 name: " SwiftFormatterPlugin " ,
32-
47+
3348 capability: . command(
3449 intent: . sourceCodeFormatting( ) ,
3550
@@ -38,7 +53,9 @@ let package = Package(
3853 ]
3954 ) ,
4055
56+
4157 dependencies: [
58+ " SwiftFormatterPluginDefaults " ,
4259 . product( name: " swiftformat " , package : " SwiftFormat " ) ,
4360 ]
4461 ) ,
Original file line number Diff line number Diff line change 55
66import Foundation
77import PackagePlugin
8+ import SwiftFormatterPluginDefaults
89
910@main
1011struct FormatterPlugin : CommandPlugin {
1112
1213 func performCommand( context: PluginContext , arguments: [ String ] ) throws {
1314 let swiftFormatTool = try context. tool ( named: " swiftformat " )
1415 let swiftFormatExec = URL ( fileURLWithPath: swiftFormatTool. path. string)
15- // let configFile = context.package.directory.appending(".swift-format.json")
1616
17+ var baseArguments : [ String ] = [ ]
18+ let fm = FileManager . default
19+ // let configFile = context.package.directory.appending(".swift-format.json").string
20+ // if fm.fileExists(atPath: configFile) {
21+ // baseArguments.append(contentsOf: ["--config", "\(configFile)"])
22+ // }
23+
24+
1725 for target in context. package . targets {
1826 guard let target = target as? SourceModuleTarget else { continue }
19-
27+
28+ var arguments = baseArguments
29+ arguments. append ( target. directory. string)
30+
2031 let process = Process ( )
2132 process. executableURL = swiftFormatExec
22- process. arguments = [
23- // "--configuration", "\(configFile)",
24- " --in-place " ,
25- " --recursive " ,
26- " \( target. directory) " ,
27- ]
33+ process. arguments = arguments
2834 try process. run ( )
2935 process. waitUntilExit ( )
3036
Original file line number Diff line number Diff line change 1+ --indent tab
Original file line number Diff line number Diff line change 1+ // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
2+ // Created by Sam Deane on 11/07/22.
3+ // All code (c) 2022 - present day, Elegant Chaos Limited.
4+ // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
5+
6+ import Foundation
7+
8+ public struct SwiftFormatterPluginDefaults {
9+ public static var defaultConfigURL : URL {
10+ return Bundle . module. url ( forResource: " default-config " , withExtension: nil ) !
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments