stephenlacy / gulp-bump

Bump any version in any file which supports semver with gulp (gulpjs.com)
MIT License
258 stars 26 forks source link

Ability to bump versions in PHP files for WordPress #66

Closed binarykitchen closed 7 years ago

binarykitchen commented 7 years ago

That would be so cool.

Something like this

  gulp.src('./index.php') // entry point of a certain wordpress plugin
  .pipe(bump({versionNew: '1.2.3', versionCurrent: '1.2.2'}))
  .pipe(gulp.dest('./'));

Reason we need current and new version is because each WordPress plugin uses different formats/variables to store them. Hence search occurences for current version and change that. Or have a better idea?

stephenlacy commented 7 years ago

regex?

binarykitchen commented 7 years ago

see https://github.com/DevinVinson/WordPress-Plugin-Boilerplate/blob/master/plugin-name/plugin-name.php#L19 for an example

probably /d+.d+.d+\ i think

stephenlacy commented 7 years ago

It is supported, pass in custom regex: https://github.com/stevelacy/bump-regex#optionsregex

binarykitchen commented 7 years ago

right thanks

binarykitchen commented 7 years ago

hmmm, looks like the problem is still here. tried with this option

  const bumpOptions = {
    regex: /d+.d+.d+/
  }

but then it complains with


events.js:182
      throw er; // Unhandled 'error' event
      ^
Error: Invalid semver: version key "version" is not found in file

cc @stevelacy

binarykitchen commented 7 years ago

to be exact, i want to bump the version in a php file like that

<?php if (!defined('ABSPATH')) exit;

/*
 * Plugin Name: abc
 * Plugin URI: ...
 * Description: ...
 * Version: 3.3.0 <--- here i want to bump this
 * Author: ...
 */

...
stephenlacy commented 7 years ago

That bumps just fine from the test I added: https://github.com/stevelacy/bump-regex/commit/8c568dd31fa27b0663934e1a18fc4e991313b0d3

stephenlacy commented 7 years ago

Don't use custom regex, the one by default works

binarykitchen commented 7 years ago

argh, my bad. works now. sorry about that!

stephenlacy commented 7 years ago

No worries!