From cffbadff7cb1717c4ff8be13e4f60060d8b2a31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Thu, 9 Jan 2025 16:18:05 +0100 Subject: [PATCH] Chore: Update version replace script to ESM --- package.json | 2 +- ...replace-version.ts => readme-replace-version.mjs} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename scripts/{readme-replace-version.ts => readme-replace-version.mjs} (64%) diff --git a/package.json b/package.json index 7ac86fe9..00673887 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "version": "yarn changelog && yarn replace-version && git status && git add CHANGELOG.md README.md package.json ./dist && git status", "postversion": "echo 'Check and push: `git push --set-upstream origin main && git push --tags`'", "release": "yarn version --`./bin/ci/semver.sh`", - "replace-version": "ts-node scripts/readme-replace-version.ts", + "replace-version": "ts-node --esm scripts/readme-replace-version.mjs", "types": "tsc -p ./tsconfig.json" }, "dependencies": { diff --git a/scripts/readme-replace-version.ts b/scripts/readme-replace-version.mjs similarity index 64% rename from scripts/readme-replace-version.ts rename to scripts/readme-replace-version.mjs index a9b88efd..b0bf5007 100644 --- a/scripts/readme-replace-version.ts +++ b/scripts/readme-replace-version.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-console */ -const replace = require('replace-in-file'); -const packageJson = require('../package.json'); +import { replaceInFile } from 'replace-in-file'; +import packageJson from '../package.json' with { type: 'json' }; -const newVersion = packageJson.version.match(/([0-9])\.[0-9]\.[0-9]/)[1]; +const newVersion = packageJson.version.match(/([0-9])\.[0-9]\.[0-9]/)?.[1]; const options = { files: 'README.md', @@ -10,11 +10,11 @@ const options = { to: `cookie-consent-manager@${newVersion}`, }; -replace(options) - .then((results: unknown) => { +replaceInFile(options) + .then((results) => { console.log('Replacement results:', results); }) - .catch((error: unknown) => { + .catch((error) => { console.error('Error occurred:', error); });