Skip to content

Add option to pass additional dependencies to hooks #293

Closed

Description

@blarghmatey

I am currently working on implementing this framework and one of the things I am trying to run is eslint. As part of that I have a number of plugins that are in my configuration file. I think that, rather than forcing anyone who is using plugins to create a new hook definition with a corresponding package.json it might be useful to add a global option to pass a list of dependencies in the configuration file.

For instance, something lilke this:

-   repo: https://github.com/pre-commit/mirrors-eslint
    sha: 135f285caf8e6e886b28c8e98fdff402b69c4490
    hooks:
    -   id: eslint
        language_version: '0.12.7'
        dependencies: [eslint-plugin-react, eslint-plugin-html]

and have those dependencies installed into the generated environment for that language.

I am going to work on implementing this in my forked repo but would like feedback on whether this is a desired feature or any implementation advice on how best to facilitate this.

Activity

  1. asottile commented on Nov 18, 2015

    @asottile
    Member

    Sounds pretty reasonable, how about additional_dependencies instead of dependencies?

    This would actually be a nice way to replace the wacky mirrors repos!

  2. blarghmatey commented on Nov 18, 2015

    @blarghmatey
    ContributorAuthor

    Yeah, that's reasonable. I'll update. I'm currently working on fixing broken tests and adding some to cover the new functionality.

  3. asottile commented on Nov 18, 2015

    @asottile
    Member

    Sounds great 👍

  4. asottile commented on Nov 23, 2015

    @asottile
    Member

    Via #295

  5. added 8 commits that reference this issue on Nov 24, 2015
    76ff413
    3a194df
    6ab7923
    04037a9
    205943c
    6576410
    248930f
    b73173f
  6. asottile commented on Nov 24, 2015

    @asottile
    Member

    derp, those commits referencing this are incorrect. That should say #294

  7. awebdeveloper commented on May 7, 2017

    @awebdeveloper

    @asottile can additional deps be files inside node_modules in case of node instead of a full npm install

  8. asottile commented on May 7, 2017

    @asottile
    Member

    I'm not sure what you mean?

  9. awebdeveloper commented on May 8, 2017

    @awebdeveloper

    My guess is when i have a node hook with additional dependency, you do npm install of the dependency. Instead of doing that can i specify the location where this dependency can be found.

    say i have a hook with additional dependency as eslint-google. Now instead of doing npm install eslint-google if it finds a file path let it use it.

  10. asottile commented on May 8, 2017

    @asottile
    Member

    I don't think that's how require(...) works?

    I think what you're reaching for is a (discouraged) system hook.

  11. awebdeveloper commented on May 8, 2017

    @awebdeveloper

    I aint asking for system hook

    Couldn't it copy this folder over to the place. I hope these packages are installed via npm install? If so i can install a local folder

  12. asottile commented on May 8, 2017

    @asottile
    Member

    The arguments in additional_dependencies are indeed passed to npm install ... -- whatever npm install takes will technically function. It might not be the best idea to include repository-specific state in there as it will be cached for all instances of that hook (with identical configuration).

  13. awebdeveloper commented on May 8, 2017

    @awebdeveloper

    My idea was to keep my package.json versions of these in sync with what's mentioned in dependency But if you think this is not a good idea i will drop it. Thanks for the info though

  14. added a commit that references this issue on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions