Skip to content

Commit

Permalink
fix(file-list): Ensure files are sorted and unique
Browse files Browse the repository at this point in the history
This was a regression from the file-list refactoring

Closes #1498, #1499
  • Loading branch information
dignifiedquire committed Jul 16, 2015
1 parent fb841a7 commit 9dc5f8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Object.defineProperty(List.prototype, 'files', {
})

var uniqFlat = function (list) {
return _.uniq(_.flatten(list), true, 'path')
return _.uniq(_.flatten(list), 'path')
}

return {
Expand Down
18 changes: 18 additions & 0 deletions test/unit/file-list.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,24 @@ describe 'FileList', ->
expect(file1.mtime).to.be.eql mg.statCache['/some/a.js'].mtime
expect(file2.mtime).to.be.eql mg.statCache['/some/b.js'].mtime

it 'should sort files within buckets and keep order of patterns (buckets)', ->
# /a.* => /a.txt [MATCH in *.txt as well]
# /some/*.js => /some/a.js, /some/b.js [/some/b.js EXCLUDED]
# *.txt => /c.txt, a.txt, b.txt [UNSORTED]
list = new List(
patterns('/a.*', '/some/*.js', '*.txt'),
['**/b.js'],
emitter,
preprocess
)

list.refresh().then (files) ->
expect(pathsFrom files.served).to.deep.equal [
'/a.txt',
'/some/a.js',
'/b.txt',
'/c.txt'
]

it 'ingores excluded files', ->
list = new List(
Expand Down

0 comments on commit 9dc5f8b

Please sign in to comment.