-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc, tools: added caching support for CHANGELOG.md
in tools/doc/versions.js
#32515
Conversation
…ons.js When running `make doc` the CHANGELOG.md file is pulled everytime for each of the doc file that requires the versions list. This commit introduces a new file called `.master-CHANGELOG.md` which will be created once so that subsequent calls for the version are pulled locally instead of from the repo. Since this file is not part of the codebase proper, it is appended in the .gitignore file. References Issue nodejs#32512
tools/doc/versions.js
Outdated
@@ -31,6 +31,13 @@ const getUrl = (url) => { | |||
}); | |||
}; | |||
|
|||
const createMaster = (masterPath, 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.
this function only is used once, why not code inline?
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.
You are right. My bad.
Thanks for the suggestion.
…angelog Review for the pull request nodejs#32515 suggested to use inline command instead of creating a function that is not used again.
if (kNoInternet) { | ||
changelog = readFileSync(file, { encoding: 'utf8' }); | ||
} else if (existsSync(masterChangelog)) { |
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.
This should probably be using statSync
and check whether the file is outdated – otherwise this isn’t caching, it’s just storing a file and keeping it around forever.
(Also, it’s odd that we use fs.*Sync()
functions inside an async
function, although it’s not that important for this script. I’d suggest using readFile
, stat
, writeFile
from fs.promises
instead, just to reflect best practices.)
When running
make doc
the CHANGELOG.md file is pulled everytime for eachof the doc file that requires the versions list. This commit introduces a
new file called
.master-CHANGELOG.md
which will be created once so thatsubsequent calls for the version are pulled locally instead of from the repo.
Since this file is not part of the codebase proper, it is appended in the
.gitignore file.
Closes #32512
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes