OT, but this should be extracted into a standalone gulp plugin with unit tests.