vojtajina / grunt-bump

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

Improvement to support setting the regex per file group. #168

Open MikeSpock opened 8 years ago

MikeSpock commented 8 years ago

Implementation for this feature request: https://github.com/vojtajina/grunt-bump/issues/131

Improvement to support setting the regex per file group. Backwards compatible with the old notation.

New Notation:

files: [
  {
    path: 'index.html',
    regexp: /(dist\/\w+\/\w+[-](([\d-]+\.)+[\d-]+))/g
  },{
    path: ['package.json', 'bower.json']
  }
]

Old Notation: files: ['package.json','index.html', 'bower.json']

If no regexp property is defined within the file, the script falls back to use the regExp prop from the bump config object. If regExp prop is not defined, it uses the built-in default regexp.

Please mind, that I didn't refine the regex matching logic within the code, so you'll have to be careful with your regexes, and mind that the code expects to get the match in a strictly defined order. Use --dry-run to check if everything is ok.

MikeSpock commented 8 years ago

any update on thes?

eddiemonge commented 8 years ago

I'm not sure I like the api for this. I think its a bit too complicated. I think the files array might be better as accepting strings and objects. If its a string, it behaves like it does now. If its an object, it requires path (as a string) and a regexp. The code itself is also harder to follow in this.

Also, the commits should be squashed and changed to follow the contributing guidelines

MikeSpock commented 8 years ago

I can squash the commits no problem, in case you'd accept this solution. Let me know if you're planning to use this or not, cause if you do, I'll do the changes.

My usecase for this was that my grunt job creates dist files in a versioned folder: dist/1.9.1/js/app.min.js and dist/1.9.1/css/app.min.css, etc, so when the grunt bump happens, I want to change the paths in my index.html.