From bbd8f08aa78b24b82ce0792c6ef01f0cf6982585 Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:01:50 +0200 Subject: [PATCH] chore: update version number in readme on release --- build/readme-version.js | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 build/readme-version.js diff --git a/build/readme-version.js b/build/readme-version.js new file mode 100644 index 0000000000..2942c8135e --- /dev/null +++ b/build/readme-version.js @@ -0,0 +1,16 @@ +/* +Replaces the version number in the readme with the current package version. +Looks for patterns like `/8.17.3/` and `/video.js@8.17.3/` +*/ + +const fs = require('fs'); +const path = require('path'); +const version = require('../package.json').version; + +let doc = fs.readFileSync(path.join(__dirname, '..', 'README.md'), 'utf8'); + +doc = doc + .replace(/\/video.js@\d\.\d+\.\d+\//g, `/video.js@${version}/`) + .replace(/\/\d\.\d+\.\d+\//g, `/${version}/`); + +fs.writeFileSync(path.join(__dirname, '..', 'README.md'), doc, 'utf8'); diff --git a/package.json b/package.json index 8a914eb5d6..225e2baab7 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "netlify": "node ./build/netlify.js", "netlify-docs": "node ./build/netlify-docs.js", "prepublishOnly": "run-p build", - "version": "is-prerelease || npm run changelog && git add CHANGELOG.md", + "version": "is-prerelease || npm run changelog && node build/readme-version.js && git add CHANGELOG.md README.md", "zip": "cd dist && cross-env bestzip \"./video-js-${npm_package_version}.zip\" * && cd .." }, "repository": {