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
Create shorter title for function tasks with many staged files #706
Conversation
Codecov Report
@@ Coverage Diff @@
## master #706 +/- ##
==========================================
+ Coverage 99.67% 99.67% +<.01%
==========================================
Files 11 11
Lines 304 307 +3
Branches 60 63 +3
==========================================
+ Hits 303 306 +3
Misses 1 1
Continue to review full report at Codecov.
|
🎉 This PR is included in version 9.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Why this call command with mockedFiles? Now my command is running two times, one of them with an array of |
@VitorLuizC the first time is to create a short title for the task. It’s not actually run, just the function evaluated to a string / array of strings. What is the command that’s failing for you? I can see if I’ve let a bug slip by. |
It seems to run my command. And to prevent erros I have to return received mocked files (that array of mockedFiles). const runLinters = files => {
if (files && files[0] === '[file]')
return files;
}
// ...
};
module.exports = {
'{applications,packages}/**/*.ts?(x)': runLinters
}; If I return an empty array or my own array of commands it throws |
I'll create an issue and probably another PR. |
The error thrown can be related to this |
@VitorLuizC if you can create a PR it would be appreciated! It seems I’ve made some assumptions that are not always true. Might be easier to just skip generating names for function tasks, though. |
// Create a matching command array with [file] in place of file names | ||
let mockCommands | ||
if (isFn) { | ||
const mockFileList = Array(commands.length).fill('[file]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think I made an error here as simple as creating the mock file array from the length of the commands array, instead of the staged files array?
To have the mock file array match the actual staged files in length, this should be:
const mockFileList = Array(commands.length).fill('[file]') | |
const mockFileList = Array(files.length).fill('[file]') |
This PR makes function task titles shorter by omitting the full list of staged filenames, instead passing them a single
[file]
as the argument. This means the task still shows the expected function, but is shorter; for exampleeslint --fix [file] && git add [file]
.The mechanism of creating the title is a bit complex, since we need to first create as long an array of
[file]
strings and evaluate the function task against it. This makes sure the output is the same as for the actual file list. After this, from a single command string multiple[file]
entries are truncated into one, so for exampleng lint --file [file] --file [file] --file [file]
turns intong lint --file [file]
.I also refactored away usages of
linter
to more generictask
andcommand
.Fixes #674