Skip to content

Commit

Permalink
build: Add standard-version updater for README
Browse files Browse the repository at this point in the history
  • Loading branch information
scroll17 committed Jun 29, 2022
1 parent 122e4a5 commit e615ff7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/standardVersionUpdater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const START_KEY_SENTENCE = 'https://img.shields.io/badge/version-';
const END_KEY_SENTENCE = '-green.svg';

function getVersion(content) {
const startIndex = content.indexOf(START_KEY_SENTENCE) + START_KEY_SENTENCE.length;
const endIndex = content.indexOf(END_KEY_SENTENCE);

return content.slice(startIndex, endIndex);
}

module.exports.readVersion = function (content) {
return getVersion(content);
};

module.exports.writeVersion = function (content, newVersion) {
const oldVersion = getVersion(content);

return content.replace(
`${START_KEY_SENTENCE}${oldVersion}${END_KEY_SENTENCE}`,
`${START_KEY_SENTENCE}${newVersion}${END_KEY_SENTENCE}`,
);
};

0 comments on commit e615ff7

Please sign in to comment.