Skip to content

Commit

Permalink
Chore: Update version replace script to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Jan 9, 2025
1 parent 7698504 commit cffbadf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* 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',
from: /cookie-consent-manager@([0-9])/gm,
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);
});

Expand Down

0 comments on commit cffbadf

Please sign in to comment.