Last active
December 19, 2018 10:34
-
-
Save ssovit/82a21867e0c4be2aee49eb032767cbf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var svgPHPArray = function (dest) { | |
var File = gutil.File; | |
var files = []; | |
var prepareFiles = function (f, enc, cb) { | |
if (f.isNull()) { | |
cb(); | |
return; | |
} | |
if (f.isStream()) { | |
cb(); | |
return; | |
} | |
var filename = f.relative.split(".").slice(0, -1).toString(); | |
files.push("\n\t\t\t\"" + filename + '" => "' + filename.replace(/\W+/g, " ").ucwords() + '"'); | |
cb(null, f); | |
}; | |
var endStream = function (cb) { | |
var content = "<?php\n\treturn array("; | |
content += files.join(","); | |
content += "\n\t\t); \n?>"; | |
var phpFile = new File(dest); | |
phpFile.path = dest; | |
phpFile.contents = new Buffer(content); | |
this.push(phpFile); | |
cb(); | |
} | |
return through.obj(prepareFiles, endStream); | |
} | |
gulp.task('svgarray', function () { | |
return gulp.src('*.svg', { | |
cwd: 'src/svg' | |
}) | |
.pipe(svgPHPArray("svg.php")) | |
.pipe(gulp.dest("config")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment