Skip to content

Commit

Permalink
Merge pull request #1109 from bradleylandis/master
Browse files Browse the repository at this point in the history
remove duplicates when combining results of multiple globs
  • Loading branch information
johanneswuerbach committed Apr 13, 2017
2 parents a1d07d9 + 7a6466c commit fb79ee7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var Chars = require('./chars');
var pad = require('./strutils').pad;
var isa = require('./isa');
var fileExists = require('./fileutils').fileExists;
var uniqBy = require('lodash.uniqby');

var knownBrowsers = require('./utils/known-browsers');
var globAsync = Bluebird.promisify(glob);
Expand Down Expand Up @@ -412,7 +413,11 @@ Config.prototype.getFileSet = function(want, dontWant, callback) {
return {src: f, attrs: attrs};
}));
});
}, []).asCallback(callback);
}, [])
.then(function(result) {
return uniqBy(result, 'src');
})
.asCallback(callback);
};

Config.prototype.getSrcFiles = function(callback) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"lodash.assignin": "^4.1.0",
"lodash.clonedeep": "^4.4.1",
"lodash.find": "^4.5.1",
"lodash.uniqby": "^4.7.0",
"mkdirp": "^0.5.1",
"mustache": "^2.2.1",
"node-notifier": "^5.0.1",
Expand Down
30 changes: 30 additions & 0 deletions tests/config_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ describe('Config', function() {
done();
});
});
it('does not return duplicates when file matches multiple globs', function(done) {
config.set('src_files', ['config_tests.js', 'config_tests.js']);
config.getSrcFiles(function(err, files) {
expect(files).to.deep.equal([fileEntry('config_tests.js')]);
done();
});
});
it('excludes using src_files_ignore', function(done) {
config.set('src_files', ['ci/*']);
config.set('src_files_ignore', ['**/report*.js']);
Expand Down Expand Up @@ -468,6 +475,17 @@ describe('Config', function() {
done();
});
});
it('does not return duplicates when file matches multiple globs', function(done) {
var egg = [ {
'attrs': [],
'src': 'testem.yml'
}];
config.set('src_files', ['t*.yml', 'testem.yml']);
config.getServeFiles(function(err, files) {
expect(files).to.deep.equal(egg);
done();
});
});
});

describe('getCSSFiles', function() {
Expand All @@ -482,6 +500,18 @@ describe('Config', function() {
done();
});
});

it('does not return duplicates when file matches multiple globs', function(done) {
config.set('cwd', 'tests');
config.set('src_files', ['fixtures/styles/*.css', 'fixtures/styles/*.css']);
config.getSrcFiles(function(err, files) {
expect(files).to.deep.equal([
fileEntry(path.join('fixtures', 'styles', 'print.css')),
fileEntry(path.join('fixtures', 'styles', 'screen.css'))
]);
done();
});
});
});

describe('browser_disconnect_timeout', function() {
Expand Down

0 comments on commit fb79ee7

Please sign in to comment.