Closed bofeizhu closed 2 years ago
Thanks for reporting this. Can you give an example of the folder structure and where you are running the command so I can verify?
To be clear, it's by design that it would use the parent directory config in addition to the config in the directory where you run the command, but not in preference to it.
Thank you for the quick reply!
Here is the folder structure:
parent - .swiftformat, .swift.... |-- child - .swiftformat, .swift...
In my case, the child folder is also a git submodule of the parent repo. So in the parent dir's .swiftformat
, I excluded the child dir to avoid unwanted changes to submodule. However, since swiftformat currently loading parent config by default, running the command in child folder would always result in the child folder get ignored. I also tried specify the config file using command --config
, but still got the same behavior.
OK, I understand the issue. There's not a really great solution for this right now, but one option is to to add --unexclude path/to/child/dir
to your swiftformat command when formatting the child directory.
Thank you! Your suggestion to add --unexclude
works!
I have probably very similar problem My folder structure is
~/Developer
.swiftformat (it contains --acronyms rule)
/My
/repo1
/repo2
.swiftformat
/SwiftFormat/swiftformat (older version of the swiftformat binary that is used by the project build phrases script)
Regardless if I provide the options directly in build phases script execution of the swiftformat
like
SwiftFormat/swiftformat "$SRCROOT" --rules ...`
or I try to provide a .swiftformat
file in the repo2
folder.
or I try to even force to use specific config by changing the build phase to execute with --config "...."
option
It seems like the tool is always looking in the parent folders recursively and sums up the rules.
In my case, it means that the repo2
is not building because the ~/Developer/My/repo2/SwiftFormat/swiftformat
is using an older version of the tool that doesn't understand the acronyms
rule.
@nicklockwood should I open another issue?
Running
swiftformat
from a child dir always ended up using the parent dir's.swiftformat
config file.