HubSpot / prettier-maven-plugin

Apache License 2.0
116 stars 23 forks source link

Can i format single file from the command line? #21

Closed GoldSubmarine closed 3 years ago

GoldSubmarine commented 4 years ago

prettier-java has the ability to format the single file

image

Can i use this plugin to format the single file via the command line?

My real needs is to register a git hook like this # option-6-shell-script

jhaber commented 4 years ago

There is not currently that ability. Maybe the prettier-maven-plugin could be updated to accept a glob, and then the shell script could compute a glob representing modified files. Does that sound like it would work for you?

jhaber commented 4 years ago

My main concern with the single-file approach is that launching a Maven process for each file has a lot of overhead

GoldSubmarine commented 4 years ago

There is not currently that ability. Maybe the prettier-maven-plugin could be updated to accept a glob, and then the shell script could compute a glob representing modified files. Does that sound like it would work for you?

Yes, it is very helpful to me. I just want the --write ability of prettier. And it uses the fast-glob library for supported glob syntax.

GoldSubmarine commented 3 years ago

Is there any plan about this?

jhaber commented 3 years ago

Sorry for the lengthy delay, I just merged #39 which should make this possible with via a command like: mvn prettier:write -Dprettier.inputGlobs=src/main/java/my/package/MyClass.java

I'll release this as part of version 0.13 shortly

GoldSubmarine commented 3 years ago

Thank you for your work.