Skip to content

Instantly share code, notes, and snippets.

@levancho
Created February 25, 2025 18:55
Show Gist options
  • Save levancho/e00855c3ec759322689957a99a157c3b to your computer and use it in GitHub Desktop.
Save levancho/e00855c3ec759322689957a99a157c3b to your computer and use it in GitHub Desktop.
const fs = require('fs');
const path = require('path');
// Read version from version-tag file
const versionTagPath = path.join(__dirname, 'version-tag');
const packageJsonPath = path.join(__dirname, 'package.json');
const version = fs.readFileSync(versionTagPath, 'utf-8').trim();
if (!version) {
console.error('No version found in version-tag file');
process.exit(1);
}
// Read package.json and update the version property
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
packageJson.version = version;
// Write updated package.json back to disk
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log(`Updated package.json to version ${version}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment