gulpjs / glob-stream

Readable streamx interface over anymatch.
MIT License
178 stars 53 forks source link

Duplicates when using multiple globs #9

Closed heikki closed 10 years ago

heikki commented 10 years ago

This is more of a question: should there be duplicates in the results?

I'm concatenating files and trying to put certain files at the beginning and rest of them to the end. Here index.js will appear twice in the end result:

gulp.src(['app/index.js', 'app/**/*.js']).pipe(concat('all.js'));

I got around it easily by writing unique plugin:

var unique = function() {
    var files = [];
    return es.map(function(file, cb) {
        if (files.indexOf(file.path) === -1) {
            files.push(file.path);
            cb(null, file);
        } else {
            cb();
        }
    });
};

ps. gulp is awesome. I just might be able to skip the whole grunt phase :)

heikki commented 10 years ago

This commit mentions filtering duplicates https://github.com/wearefractal/glob-stream/commit/408ad748596639c38a374b462aa71f1e22e9e296 but combine-stream doesn't have those options.

yocontra commented 10 years ago

Nice find - will fix this when I get a minute by adding my own dedupe