vojtajina / grunt-bump

Grunt.js plugin - Increment package version.
MIT License
651 stars 122 forks source link

feat: support regexp as function #189

Closed ctjhoa closed 6 years ago

ctjhoa commented 8 years ago

This is useful if you want to reuse options in the RegExp. eg:

grunt.initConfig({
  bump: {
    options: {
      regExp: function() {
        return new RegExp('' + grunt.task.current.options.prereleaseName + '');
      }
    }
  }
});
eddiemonge commented 8 years ago

Can you give an example of how this is useful?

ctjhoa commented 8 years ago

Take a look at https://github.com/csnover/TraceKit/pull/64/commits/1e6703b5f3543e8a9b268648bf22de146e07ba5c

I was forced to create a new gruntBumpPrereleaseName to remove the dot which cause issue #190

With this PR you can reuse directly grunt current task variables.

eg.

regExp:  function() {
    return new RegExp('([\'|\"]?version[\'|\"]?[ ]*:[ ]*[\'|\"]?)(\\d+\\.\\d+\\.\\d+(-' +
        grunt.task.current.options.prereleaseName +
        '\\.\\d+)?(-\\d+)?)[\\d||A-a|-]*([\'|\"]?)', 'i'
    );
}
ctjhoa commented 6 years ago

@eddiemonge Updated. Sorry for the late reply I didn't notice your request change.

ctjhoa commented 6 years ago

@eddiemonge done