Skip to content

Instantly share code, notes, and snippets.

@ssovit ssovit/svgPHPArray.js
Last active Dec 19, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.