grunt-bump icon indicating copy to clipboard operation
grunt-bump copied to clipboard

Improvement to support setting the regex per file group.

Open MikeSpock opened this issue 9 years ago • 3 comments

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 avatar Nov 27 '15 09:11 MikeSpock

any update on thes?

MikeSpock avatar Dec 08 '15 15:12 MikeSpock

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

eddiemonge avatar Dec 08 '15 19:12 eddiemonge

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.

MikeSpock avatar Dec 10 '15 10:12 MikeSpock