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

doc, tools: added caching support for CHANGELOG.md in tools/doc/versions.js #32515

Closed
wants to merge 2 commits into from

Conversation

hassaanp
Copy link
Contributor

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.

Closes #32512

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

…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
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory. labels Mar 27, 2020
@@ -31,6 +31,13 @@ const getUrl = (url) => {
});
};

const createMaster = (masterPath, file) => {
Copy link
Member

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?

Copy link
Contributor Author

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)) {
Copy link
Member

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.)

@richardlau
Copy link
Member

Apologies to @hassaanp I've had a in progress change for this on my backlog for awhile and was able to finish it today (since I'm off work today): #32518

@hassaanp
Copy link
Contributor Author

Apologies to @hassaanp I've had a in progress change for this on my backlog for awhile and was able to finish it today (since I'm off work today): #32518

No worries. You can go ahead and close this if you want.

@hassaanp hassaanp closed this Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tools/doc/versions.js should cache version data
5 participants