-
Notifications
You must be signed in to change notification settings - Fork 139
Check and generate multiple readme files in one package #282
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
Changes from 15 commits
12a17ea
a3886c0
ae666b8
0981abe
d57e8ba
7ef4eb5
3e762da
303bb12
17afb55
4f603f8
5898df2
6cf1ce4
e5983ce
380019c
41c2ff2
9d9039c
9a85bb5
da89e55
cb3e976
9ff5e57
1673749
d24311c
17506c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ package cmd | |
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/pkg/errors" | ||
| "github.com/spf13/cobra" | ||
|
|
||
|
|
@@ -44,12 +43,28 @@ func lintCommandAction(cmd *cobra.Command, args []string) error { | |
| return errors.Wrap(err, "locating package root failed") | ||
| } | ||
|
|
||
| ok, err := docs.IsReadmeUpToDate() | ||
| readmeFiles, err := docs.AreReadmesUpToDate() | ||
| if err != nil { | ||
| return errors.Wrapf(err, "can't check if %s file is up-to-date", docs.ReadmeFile) | ||
| return errors.Wrap(err, "checking readme files are up-to-date failed") | ||
| } | ||
|
|
||
| outdatedStr := "" | ||
| errStr := "" | ||
| for _, f := range readmeFiles { | ||
| if !f.UpToDate { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to capture all outdated file names here to display in the error message. It's not pretty again. Is there a better way to do so?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the other comment I suggested to return an error if something bad happens. You can check if |
||
| outdatedStr += f.FileName + " " | ||
| } | ||
| if f.Error != nil { | ||
| errStr += f.FileName + " " | ||
| } | ||
| } | ||
| if !ok { | ||
| return fmt.Errorf("%s file is outdated. Rebuild the package with 'elastic-package build'", docs.ReadmeFile) | ||
|
|
||
| if outdatedStr != "" { | ||
| return fmt.Errorf("%s are outdated. Rebuild the package with 'elastic-package build'", outdatedStr) | ||
| } | ||
|
|
||
| if errStr != "" { | ||
| return errors.Wrapf(err, "check if %s are up-to-date failed", errStr) | ||
| } | ||
|
|
||
| err = validator.ValidateFromPath(packageRootPath) | ||
|
|
||
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.
What is the case that the target is empty?
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.
It will be empty when README file is static and can't be generated from the template file. This came from
generateReadme(fileName, packageRoot)function.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.
Ah I see! It might be cleaner to skip this file on the lower layer (in the
docs.UpdateReadmes()), so "" (empty string) won't leak here.