-
Notifications
You must be signed in to change notification settings - Fork 3
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
Template variable for file created date vs modified date? #20
Comments
Hey @robross0606 , |
Hey @robross0606, config/copyright.js /**
* Copyright (c) <%= YEAR_CREATED %>-<%= YEAR %>
*/ .eslintrc {
"notice/notice":["error",
{
templateFile:"config/copyright.js",
templateVars:{YEAR_CREATED: async ({fullFilePath}) => {
const {stdout} = await execp(`git log --follow --format=%ad --date default ${fullFilePath} | tail -1`);
const date = new Date(stdout);
return date.getFullYear();
}},
varRegexps:{YEAR_CREATED: async ({fullFilePath,templateVarValue}) => templateVarValue}
}
]
} Essentially, you can change the value based on the fullFilePath, and also change the pattern. Let me know what you think! |
The idea of being able to shim your own functions to feed variables seems like a great, flexible way to approach this. If you're interested specifically in an example of getting the git date span, check out https://github.com/shybyte/copyright-header. As for overhead, we'll probably be running this specifically using |
Hey @robross0606 , I still think my idea might make the most sense? I think what I dislike the most about Either way, I always offer the person who made the issue the ability to implement themselves before I try. I'm very generous with accepting MRs because I just want other people to understand this code. If not, I will try to implement it in the next week or so. Best, |
Our copyright notices need to be different based on when the file was originally created vs. modified. Examples:
I see there's a template variable that exists for
YEAR
but that's the current date. Is there a way to obtain the original create date of the file? Is there a way to do conditionals if the created date doesn't matchYEAR
? Or, even more accurately, something like the earliest year from thegit
file commit.The text was updated successfully, but these errors were encountered: