Skip to content

Commit 9dc5f8b

Browse files
committedJul 16, 2015
fix(file-list): Ensure files are sorted and unique
This was a regression from the file-list refactoring Closes #1498, #1499
1 parent fb841a7 commit 9dc5f8b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎lib/file-list.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Object.defineProperty(List.prototype, 'files', {
228228
})
229229

230230
var uniqFlat = function (list) {
231-
return _.uniq(_.flatten(list), true, 'path')
231+
return _.uniq(_.flatten(list), 'path')
232232
}
233233

234234
return {

‎test/unit/file-list.spec.coffee

+18
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,24 @@ describe 'FileList', ->
268268
expect(file1.mtime).to.be.eql mg.statCache['/some/a.js'].mtime
269269
expect(file2.mtime).to.be.eql mg.statCache['/some/b.js'].mtime
270270

271+
it 'should sort files within buckets and keep order of patterns (buckets)', ->
272+
# /a.* => /a.txt [MATCH in *.txt as well]
273+
# /some/*.js => /some/a.js, /some/b.js [/some/b.js EXCLUDED]
274+
# *.txt => /c.txt, a.txt, b.txt [UNSORTED]
275+
list = new List(
276+
patterns('/a.*', '/some/*.js', '*.txt'),
277+
['**/b.js'],
278+
emitter,
279+
preprocess
280+
)
281+
282+
list.refresh().then (files) ->
283+
expect(pathsFrom files.served).to.deep.equal [
284+
'/a.txt',
285+
'/some/a.js',
286+
'/b.txt',
287+
'/c.txt'
288+
]
271289

272290
it 'ingores excluded files', ->
273291
list = new List(

0 commit comments

Comments
 (0)
Please sign in to comment.