lazd / gulp-replace

A string replace plugin for gulp
MIT License
496 stars 88 forks source link

Support async replacement #95

Open perrin4869 opened 6 years ago

perrin4869 commented 6 years ago

This could be useful when doing an async calculation of the replacement text (for example, compiling some javascript, etc). I could try to put together a PR this week :)

perrin4869 commented 6 years ago

I am thinking to add a new async option, besides skipBinary. When true, the replacement function will return a promise. Since neither String.prototype.replace nor replacestream support a replacement function that resolves, the logic for the async case would be separate from the sync one... basically converting the vinyl file's contents to a string, and then executing the replacement asynchronously.

perrin4869 commented 6 years ago

The other option would be to export a separate, async version of the plugin

LvChengbin commented 5 years ago

@perrin4869 did the async version release?

mrweiner commented 2 years ago

@lazd any chance of getting this feature added, given that a PR doesn't seem to have ever been created?

lazd commented 2 years ago

@mrweiner super low without a PR, I don't have incentive or time to add this feature myself.