Skip to content

Commit 5542090

Browse files
authored
Add --paths argument to only lint specific paths (airbnb#177)
1 parent 503c5bc commit 5542090

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Plugins/FormatSwift/Plugin.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ struct AirbnbSwiftFormatPlugin: CommandPlugin {
2020
// specifying the targets selected in the plugin dialog.
2121
let inputTargets = argumentExtractor.extractOption(named: "target")
2222

23-
var inputPaths: [String]
23+
// If given, lint only the paths passed to `--paths`
24+
var inputPaths = argumentExtractor.extractOption(named: "paths")
25+
2426
if !inputTargets.isEmpty {
2527
// If a set of input targets were given, lint/format the directory for each of them
26-
inputPaths = try context.package.targets(named: inputTargets).map { $0.directory.string }
27-
} else {
28-
// Otherwise if no targets we listed we default to linting/formatting
28+
inputPaths += try context.package.targets(named: inputTargets).map { $0.directory.string }
29+
} else if inputPaths.isEmpty {
30+
// Otherwise if no targets or paths listed we default to linting/formatting
2931
// the entire package directory.
3032
inputPaths = try self.inputPaths(for: context.package)
3133
}

0 commit comments

Comments
 (0)