import_sorter icon indicating copy to clipboard operation
import_sorter copied to clipboard

Pre-commit hook doesn't work with custom dart/flutter executable locations

Open lig opened this issue 5 years ago • 3 comments

At the moment, the pre-commit hook definition expects dart/flutter executables to be accessible in the search path.

However, it is a common practice to install several channels on the same machine and use different executable names for them. i.e. flutter-stable, dart-beta, etc.

It is possible to implement a hook that takes an executable name/path as an argument in the args parameter, see https://pre-commit.com/#passing-arguments-to-hooks. However, this requires transforming the definition in the script type and using an additional script that would construct the corresponding command to execute. The problem is we cannot just use bash for this as Windows users won't be able to use it.

lig avatar Dec 28 '20 00:12 lig

Another option is to use python hook type as a wrapper. From the pre-commit docs: Support: python hooks work without any system-level dependencies. It has been tested on linux, macOS, windows, and cygwin. https://pre-commit.com/#python

A simple python script will work on any platform and it is easy enough to parse arguments and invoke the proper command from it.

lig avatar Dec 28 '20 00:12 lig

Well, according to the docs the entire repo must be installable as a python package. This will require some additional files in the repo root. Seems a bit inconvenient.

lig avatar Dec 28 '20 00:12 lig

See #63

gleich avatar Dec 07 '21 20:12 gleich