Skip to content

Instantly share code, notes, and snippets.

@mikaelbr
Last active January 2, 2016 03:59
Show Gist options
  • Save mikaelbr/8247656 to your computer and use it in GitHub Desktop.
Save mikaelbr/8247656 to your computer and use it in GitHub Desktop.
Possible gulp plugin for having independent sub directories.
var es = require("event-stream"),
path = require("path"),
gulp = gulp("fs");
var dest = module.exports = function (matcher) {
"use strict";
function dest(file, callback) {
if (file.isNull()) return cb(null, file); // pass along
if (!matcher) {
callback(new Error("gulp-subdir: No subdirectory specified"), undefined);
}
var writePath = path.join(path.dirname(file.path), matcher);
return gulp.dest(writePath)(file, callback);
}
return es.map(subdir);
};
// Usage:
gulp.src("someDirectory/*/*.less")
.pipe(less())
.pipe(dest("./"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment