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

Add ability to customize start/end of each generated file #515

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jeffpearce
Copy link

This PR adds two properties to the options, to allow per-file customization. For example, you can use this to turn swiftlint on and off, but there are other uses.

[modules.MyProject.options]

# You can add prefix lines to the beginning of each file written, and suffix lines to the end
# For example, this config can be used to turn swiftlint off at the start and back on at the end
prefixLines = [
    "// swiftlint:disable all",
]
SuffixLines = [
    "// swiftlint:enable all",
]

@MatyasKriz
Copy link
Collaborator

Hey, thanks for the PR, although I don't believe the generator needs this functionality. I'd like to keep the configuration as simple as can be. Not saying that customization is bad, we've already got nearly infinitely customizable mock names, it's just that these file prefixes/suffixes can be supplemented by a bash line if a project needs it.

What other use-cases have you got in mind for this new feature?

@jeffpearce
Copy link
Author

Hey, thanks for looking!

My first approach actually was to run a shell script that uses sed to in add the lines. Unfortunately, there's a race condition under parallel builds, since the script can be called from two different projects, causing the lines to be added twice. I have other ideas to fix it, but if I look at our build as a whole the "simplest" approach is for the generator to be able to output what we need in one step.

As far as other uses, I could envision someone wanting to inject a copyright header into the generated mocks file. Not important to me, but I've worked places where stuff like that was important.

@aiKrice
Copy link

aiKrice commented Oct 8, 2024

Agree, more over, yo ucan just exclude swiftlint from these files or from other tools

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

Successfully merging this pull request may close these issues.

3 participants