Skip to content
Snippets Groups Projects
Select Git revision
  • c6722b819491604eb618087dafdfd64d761a8335
  • dev default protected
  • prod protected
  • 1.0.58
  • 1.0.57
  • 1.0.52
  • 1.0.56
  • 1.0.51
  • 1.0.50
  • 1.0.33
  • 1.0.32
  • 1.0.31
  • 1.0.30
  • 1.0.29
  • 1.0.28
  • 1.0.27
  • 1.0.26
  • 1.0.25
  • 1.0.24
  • 1.0.23
  • 1.0.22
  • 1.0.21
  • 1.0.20
23 results

update-version.js

Blame
  • update-version.js 924 B
    const fs = require('fs');
    
    // Read version from package.json
    const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
    const version = packageJson.version;
    
    // Files to update
    const filesToUpdate = ['composer.json', 'etc/module.xml'];
    
    // Function to update version in files
    function updateVersionInFile(filePath) {
      let content = fs.readFileSync(filePath, 'utf8');
    
      if (filePath === 'composer.json') {
        // Update the Version header in the plugin file
        // Update the version in composer.json
        content = content.replace(
            /(\"version\":\s*\")([0-9.]+)(\"\,)/g,
            `$1${version}$3`
        );
      }
    
      if (filePath === 'etc/module.xml') {
        // Update the version tag in etc/module.xml
        content = content.replace(
          /(setup_version=")([^"]*)/g,
          `$1${version}`
        );
    
      }
    
      fs.writeFileSync(filePath, content);
    }
    
    // Update each file
    filesToUpdate.forEach(updateVersionInFile);