-
Notifications
You must be signed in to change notification settings - Fork 37
Request: default task: format #168
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
Comments
It's quite easy to use pub global run from grinder (does activate automatically) |
Yeah, currently using it would look something like this:
It will take care of activating the tool if it does not exist on the system. I'd be happy w/ a PR that added a semantic wrapper around the |
Although, if dartfmt is generally run from the sdk, and not via pub global activate, then we should have a 1st class wrapper around it in grinder (and one that doesn't drive it via pub global activate). |
IMO, the fact that |
Regardless, I think grinder should ship with a dartfmt task. Since dartfmt ships with the SDK, we can assume it exists. Could the built-in dartfmt task just use whatever is on the command line? |
It would be a bit more discoverable if
|
Are you more interested in validating the formatting or actually formatting? By default would it run over all dart files in the project? Would it require glob support for non-default use cases? (dart_style doesn't appear to support this natively yet) Do you want to be able to pass command-line arguments (#116 and #175) for which files to format? |
If we depend on what's on the command-line, that's unpredictable. I think the user should be explicit about which version they want. Could be two separate constructors: new Dartfmt.sdk().format(...)
new Dartfmt.pub().format(...) Or if dartfmt supported --version, then the user could specify a version constraint, and it could first check if the pub version is already activated, and if that matches the version constraint, then use it, otherwise check if the SDK dartfmt matches the version constraint, otherwise activate the pub version with that version constraint (see #165): new Dartfmt(version: '^0.1.7').format(...) |
Maybe DartFormat could be just a subclass of PubApp where the name ('dart_style') is predefined, to ensure the API stays consistent |
@zoechi That might work, although the If we go with constructor(s) i.e. |
@seaneagan two tasks: validate formatting, and actually do the formatting. I'd like to run: Ultimately, I'm trying to create tasks and workflows to automate my day-to-day source code and development and test and release workflows. |
Lets plan on having the default formatting functionality in grinder be a wrapper around the sdk tool - If we want to have a formatter with a similar API, backed by an activated dart_style package, we could do that. But I think that would have to be something that the user would explicitly request. The sdk one should be the default for consistency with the other sdk tools. |
Now that we have the ability to ship
It might even make sense at some point to remove those executables from the SDK proper, and the various OS dart packages (homebrew, chocolatey, docker, etc.) could still install them by running the following if desired:
|
It's exposed in the source in the repo; we may change how it's exposed as per #204. |
I'd love it if grinder had a default talk for 'format' which ran dart_style's dartfmt over my project.
Thanks!
The text was updated successfully, but these errors were encountered: