Skip to content

Commit 5fac9e1

Browse files
authored
chore: update version number in readme on release (#8840)
Updates the version number where it appears in URLs in the README, when `nom version` is ran. It's looking specifically for patterns like `/8.17.3/` and `/video.js@8.17.3/`; if we change the README we need to consider this script.
1 parent fa7e648 commit 5fac9e1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

build/readme-version.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Replaces the version number in the readme with the current package version.
3+
Looks for patterns like `/8.17.3/` and `/video.js@8.17.3/`
4+
*/
5+
6+
const fs = require('fs');
7+
const path = require('path');
8+
const version = require('../package.json').version;
9+
10+
let doc = fs.readFileSync(path.join(__dirname, '..', 'README.md'), 'utf8');
11+
12+
doc = doc
13+
.replace(/\/video.js@\d\.\d+\.\d+\//g, `/video.js@${version}/`)
14+
.replace(/\/\d\.\d+\.\d+\//g, `/${version}/`);
15+
16+
fs.writeFileSync(path.join(__dirname, '..', 'README.md'), doc, 'utf8');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"netlify": "node ./build/netlify.js",
7878
"netlify-docs": "node ./build/netlify-docs.js",
7979
"prepublishOnly": "run-p build",
80-
"version": "is-prerelease || npm run changelog && git add CHANGELOG.md",
80+
"version": "is-prerelease || npm run changelog && node build/readme-version.js && git add CHANGELOG.md README.md",
8181
"zip": "cd dist && cross-env bestzip \"./video-js-${npm_package_version}.zip\" * && cd .."
8282
},
8383
"repository": {

0 commit comments

Comments
 (0)