Skip to content
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

Allow custom templates #4

Open
atifsyedali opened this issue Nov 21, 2019 · 5 comments
Open

Allow custom templates #4

atifsyedali opened this issue Nov 21, 2019 · 5 comments

Comments

@atifsyedali
Copy link

  • I'm submitting a ...
    [ ] bug report
    [x] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Allow specifying a custom template by pointing to a template file.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

@shybyte
Copy link
Owner

shybyte commented Nov 28, 2019

@atifsyedali
Currently the hard coded templates get 3 variables:

  • from - The start year (example: 2017)
  • to - The last modification year if different from the start year prefixed with a hyphen (example: -2019)
  • copyrightHolder - Configured by the command line option

These variables appear in the template prefixed with an $, like for example:
/* Copyright (c) $from$to $copyrightHolder */

Is this simple home grown template system sufficient for your needs or do need a more elaborated template system?

@atifsyedali
Copy link
Author

Hi,

It would have been nice to allow input of a file and keep those three variables. So for example, I have a copyright header that looks like...

copyrightFile.txt in my project's root:

/*******************************************************************************
 * © $copyrightHolder, $from-$to
 * All Rights Reserved.
 ******************************************************************************/

and then in the input you can just do --templateFile ./copyrightFile.txt instead of using templateId.

@shybyte
Copy link
Owner

shybyte commented Dec 3, 2019

@atifsyedali This should be actually a simple change, but unfortunately I have zero time this week.
So I will implement it next week. If this is to late for you, feel free to make a PR!

@atifsyedali
Copy link
Author

@shybyte TBH I started this change but then someone pointed to me https://github.com/Stuk/eslint-plugin-header so I have switched over to that.

I am going to create a PR with what I have so far.

@robross0606
Copy link

@atifsyedali, I too looked at both of these options. I'm surprised you switched over to https://github.com/Stuk/eslint-plugin-header. It offers custom templates, but does not offer good handling of date ranges. To my knowledge, it also does not support any analysis of git history at all. I'm curious if you found some way to make that plugin do what this one already does because I have the same problem. This tool almost does exactly what I need except for a couple things:

  • Easy integration as a git commit hook (i.e. target staged files).
  • Using a custom template since our format does not use the ''" between date ranges as this generates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants