Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to specify an output file for SwiftLint reports instead of using '>' ? #4048

Closed
tychop opened this issue Jul 27, 2022 · 3 comments · Fixed by #4148
Closed
Labels

Comments

@tychop
Copy link

tychop commented Jul 27, 2022

I want to save a json report of my SwiftLint BuildToolPlugin so I can use it elsewhere.

I am currently trying the following:

import PackagePlugin

@main
struct SwiftLintPlugin: BuildToolPlugin {
	func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
		return [
			.buildCommand(
				displayName: "Running SwiftLint for \(target.name)",
				executable: try context.tool(named: "swiftlint").path,
				arguments: [
					"lint",
					"--in-process-sourcekit",
					"--path", "\(target.directory.string)",
					"--config", "\(context.package.directory.string)/.swiftlint.yml",
					"--reporter", "json",
					">", "swiftlint.result.json"
				],
				environment: [:]
			)
		]
	}
}

But that basically boils down to the following command in which the quotes around the '>' character prevents creating an output file.

swiftlint lint \
	--in-process-sourcekit \
	--path BusinessModel \
	--config .swiftlint.yml \
	--reporter json ">" swiftlint.result.json

Is there any way to specify an output file for SwiftLint reports instead of using '>' ?

@SimplyDanny
Copy link
Collaborator

As far as I see, there is currently no other way to write the report to a file.

One option is to support that in SwiftLint. Another one is to convince the maintainers of swift-tools-support-core to avoid escaping of single arguments like >, |, 2>, ... This should be the responsible line in their code.

@jpsim
Copy link
Collaborator

jpsim commented Aug 30, 2022

@tychop can you please check out #4148 and let me know if it's what you're looking for?

jpsim added a commit that referenced this issue Aug 31, 2022
To write to a file instead of to stdout.

Addresses #4048
@tychop
Copy link
Author

tychop commented Dec 13, 2022

This works excellent !!! Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants