gulp-inject-string icon indicating copy to clipboard operation
gulp-inject-string copied to clipboard

Add a custom method

Open evanre opened this issue 6 years ago • 5 comments

Hi, I need to make something more difficult than just string replace. And I think about implementing custom method that will give us ability to make any manipulations with strings on javascript.

For example. I've faced with problem when on my gulp environment I've needed parse regex occurrence and return different strings. Here is my working code: .pipe($.injectString.custom(function (str) { return str.replace(new RegExp('(z-var\\s*:\\s*)(\\w*)(.*;)', 'g'), function (match, g1, g2, g3) { return '{' + g2 + '}'; }); })

This function find and replace z-var: varName; to {varName}

Created a pull request. #12

evanre avatar Jun 22 '18 13:06 evanre

Hi @mikehazell, could you please take a look on my pull request?

evanre avatar Jul 26 '18 10:07 evanre

Hi @mikehazell, just a ping in hope You'll answer.

evanre avatar Sep 25 '18 08:09 evanre

+1

evanre avatar Nov 24 '18 09:11 evanre

It's been a year passed and no reaction. @mikehazell is this package still supported?

evanre avatar Jul 10 '19 09:07 evanre

Hey @evanre, sorry. I don't really use gulp anymore so this just doesn't make my priority list very often.

I've merged in your changes and added another PR which would resolve #5 and #8. There was some confusion around regex's which I hope this will solve.

Would love your feedback and if you could test this in a project to see if I broke anything I wasn't expecting. See this PR #17.

These 2 prs will be released together as major version bump v2.0.0.

mikehazell avatar Jul 12 '19 12:07 mikehazell