mikehazell / gulp-inject-string

Inject snippets in build
MIT License
39 stars 12 forks source link

Add a custom method #13

Open evanre opened 6 years ago

evanre commented 6 years ago

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 commented 6 years ago

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

evanre commented 5 years ago

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

evanre commented 5 years ago

+1

evanre commented 5 years ago

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

mikehazell commented 5 years ago

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.