diff --git a/.gitignore b/.gitignore index 425a5ddbec0fca..fbeb441c1f3924 100644 --- a/.gitignore +++ b/.gitignore @@ -135,6 +135,7 @@ _UpgradeReport_Files/ # === Global Rules === # Keep last to avoid being excluded *.pyc +.master-CHANGELOG.md __pycache__ .DS_Store *~ diff --git a/tools/doc/versions.js b/tools/doc/versions.js index bff6ac3617fbde..2d1bb9425d678b 100644 --- a/tools/doc/versions.js +++ b/tools/doc/versions.js @@ -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, '..', '..'); @@ -45,11 +45,16 @@ 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)) { + changelog = readFileSync(masterChangelog, { encoding: 'utf8' }); } else { try { changelog = await getUrl(url); + // Create the .master-CHANGLELOG.md file + writeFileSync(masterChangelog, changelog); } catch (e) { // Fail if this is a release build, otherwise fallback to local files. if (isRelease()) {