-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
doc, tools: added caching support for CHANGELOG.md in tools/doc/versions.js
#32515
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 1 commit
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| 'use strict'; | ||
|
|
||
| const { readFileSync } = require('fs'); | ||
| const { readFileSync, existsSync, writeFileSync } = require('fs'); | ||
| const path = require('path'); | ||
| const srcRoot = path.join(__dirname, '..', '..'); | ||
|
|
||
|
|
@@ -31,6 +31,13 @@ const getUrl = (url) => { | |
| }); | ||
| }; | ||
|
|
||
| const createMaster = (masterPath, file) => { | ||
| writeFileSync( | ||
| masterPath, | ||
| file, { encoding: 'utf8' } | ||
| ); | ||
| }; | ||
|
|
||
| const kNoInternet = !!process.env.NODE_TEST_NO_INTERNET; | ||
|
|
||
| module.exports = { | ||
|
|
@@ -45,11 +52,15 @@ module.exports = { | |
| 'https://raw.githubusercontent.com/nodejs/node/master/CHANGELOG.md'; | ||
| let changelog; | ||
| const file = path.join(srcRoot, 'CHANGELOG.md'); | ||
| const masterChangelog = path.join(srcRoot, '.master-CHANGELOG.md'); | ||
| if (kNoInternet) { | ||
| changelog = readFileSync(file, { encoding: 'utf8' }); | ||
| } else if (existsSync(masterChangelog)) { | ||
|
Member
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. This should probably be using (Also, it’s odd that we use |
||
| changelog = readFileSync(masterChangelog, { encoding: 'utf8' }); | ||
| } else { | ||
| try { | ||
| changelog = await getUrl(url); | ||
| createMaster(masterChangelog, changelog); | ||
| } catch (e) { | ||
| // Fail if this is a release build, otherwise fallback to local files. | ||
| if (isRelease()) { | ||
|
|
||
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.