Skip to content

Commit

Permalink
Build: Add version release number in unreleased docs
Browse files Browse the repository at this point in the history
Closes #1621.
  • Loading branch information
ventuno committed Jun 5, 2021
1 parent 47576c1 commit 20f746f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions build/prep-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,31 @@ const util = require( "util" );
const cp = require( "child_process" );
const gitAuthors = require( "grunt-git-authors" );

function parseLineResults( output = "" ) {
return output.trim().split( "\n" );
}

function versionAddedString( version ) {
return `version_added: "${version}"`;
}

const Repo = {
async prep( version ) {
if ( typeof version !== "string" || !/^\d+\.\d+\.\d+$/.test( version ) ) {
throw new Error( "Invalid or missing version argument" );
}
{
const UNRELEASED_VERSION = versionAddedString( "unreleased" );
parseLineResults( cp.execSync(
`grep -l '${UNRELEASED_VERSION}' docs/**/*.md`,
{ encoding: "utf8" } )
).forEach( filePath => {
const doc = fs.readFileSync( filePath, "utf8" );
fs.writeFileSync( filePath,
doc.replace( UNRELEASED_VERSION, versionAddedString( version ) )
);
} );
}
{
const file = "History.md";
console.log( `Updating ${file}...` );
Expand All @@ -38,9 +58,7 @@ const Repo = {
`${oldVersion}...HEAD`
], { encoding: "utf8" } );

changes = changes
.trim()
.split( "\n" )
changes = parseLineResults( changes )
.filter( line => !changeFilter.some( filter => filter.test( line ) ) )
.map( line => {
return {
Expand Down

0 comments on commit 20f746f

Please sign in to comment.