jcberquist / commandbox-cfformat

A CommandBox module for formatting CFML component files.
MIT License
22 stars 10 forks source link

cfformat watch doesn't find the correct .cfformat.json file like cfformat run does. #65

Open gpickin opened 4 years ago

gpickin commented 4 years ago

Because the user settings are based on the location of the file being formatted, it doesn't resolve and find the .cfformat.json file correctly, therefore the files are formatted incorrectly.

jcberquist commented 4 years ago

Hi @gpickin, I am not sure I follow, could you give me an example of the issue?

MordantWastrel commented 4 years ago

We ran into this today. Using cfformat run, it will use the .cfformat.json` file in the root of our app.

Using cfformat watch ./, it used what I presume are default settings.

The behavior wasn't consistent - might be that if we ran cfformat run first and then cfformat watch it would use the correct rules. cfformat settings showed us the right settings every time.

Platform: Linux (WSL2)

jcberquist commented 4 years ago

@MordantWastrel Thanks, that is helpful. Reading your comment, I realized that watch is technically using globs, and I bet the settings resolution isn't function correctly on those. The solution is probably going to be resolving the settings a file at a time.

jcberquist commented 4 years ago

So my memory of how the settings resolution is performed was faulty, it is in fact already resolved per file. So I am not sure where this issue is coming from. I have published v0.15.6 which will provide more feedback when watching files as to where the settings it is using are coming from. Hopefully that will help narrow this down.

CreativeNotice commented 3 years ago

Using v0.15.13. Not seeing the source of the settings when running a watch. If I explicitly define the settingsPath the full path to my .cfformat.json is displayed as expected.

CommandBox:traverseapisdk> cfformat watch ./

Watching Files...
Formatting helpers\utility.cfc
Setting sources:    

Formatting took 94ms
jcberquist commented 3 years ago

@CreativeNotice I can't reproduce this locally, which is frustrating. When CFFormat is searching for config files it starts in the directory of the file to be formatted and then climbs up the directory tree to the drive root looking for .cfformat.json files. It stops when it either encounters a .cfformat.json file, or sees a .git/ directory in the current directory it is checking. So, for example, taking your output above, if your helpers/ directory has a .git/ folder in it, it wouldn't search above that directory. Absent that, I am not sure why it wouldn't find your .cfformat.json file in the parent directory.