Merge pull request #3313 from realm/ks/add-support-for-params-files-for-file-path-arguments

Add support for params files for file path arguments
This commit is contained in:
JP Simard 2020-08-21 08:13:06 -07:00 committed by GitHub
commit e677737fe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -10,7 +10,8 @@
#### Enhancements
* None.
* Add support for params files for file paths.
[keith](https://github.com/keith)
#### Bug Fixes

View File

@ -28,6 +28,16 @@ enum LintOrAnalyzeModeWithCompilerArguments {
case analyze(allCompilerInvocations: CompilerInvocations)
}
private func resolveParamsFiles(args: [String]) -> [String] {
return args.reduce(into: []) { allArgs, arg in
if arg.hasPrefix("@"), let contents = try? String(contentsOfFile: String(arg.dropFirst())) {
allArgs += resolveParamsFiles(args: contents.split(separator: "\n").map(String.init))
} else {
allArgs.append(arg)
}
}
}
struct LintableFilesVisitor {
let paths: [String]
let action: String
@ -44,7 +54,7 @@ struct LintableFilesVisitor {
init(paths: [String], action: String, useSTDIN: Bool, quiet: Bool, useScriptInputFiles: Bool, forceExclude: Bool,
cache: LinterCache?, parallel: Bool,
allowZeroLintableFiles: Bool, block: @escaping (CollectedLinter) -> Void) {
self.paths = paths
self.paths = resolveParamsFiles(args: paths)
self.action = action
self.useSTDIN = useSTDIN
self.quiet = quiet
@ -61,7 +71,7 @@ struct LintableFilesVisitor {
useScriptInputFiles: Bool, forceExclude: Bool,
cache: LinterCache?, compilerInvocations: CompilerInvocations?,
allowZeroLintableFiles: Bool, block: @escaping (CollectedLinter) -> Void) {
self.paths = paths
self.paths = resolveParamsFiles(args: paths)
self.action = action
self.useSTDIN = useSTDIN
self.quiet = quiet