Skip to content

Commit

Permalink
chore(dependencies): keep old behavior and stricten test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Bridgewater committed Feb 17, 2016
1 parent 7fc6285 commit 2df7811
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ List.prototype._refresh = function () {
var self = this
var buckets = this.buckets

return Promise.map(this._patterns, function (patternObject) {
var promise = Promise.map(this._patterns, function (patternObject) {
var pattern = patternObject.pattern

if (helper.isUrlAbsolute(pattern)) {
Expand All @@ -167,7 +167,7 @@ List.prototype._refresh = function () {
return
}

return Promise.all(files.map(function (path) {
return Promise.map(files, function (path) {
if (self._isExcluded(path)) {
log.debug('Excluded file "%s"', path)
return Promise.resolve()
Expand All @@ -185,7 +185,7 @@ List.prototype._refresh = function () {
return self._preprocess(file).then(function () {
return file
})
}))
})
.then(function (files) {
files = _.compact(files)

Expand All @@ -197,10 +197,15 @@ List.prototype._refresh = function () {
})
})
.then(function () {
if (self._refreshing !== promise) {
return self._refreshing
}
self.buckets = buckets
self._emitModified(true)
return self.files
})

return promise
}

// Public Interface
Expand Down
14 changes: 12 additions & 2 deletions test/unit/file-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,20 @@ describe('FileList', () => {

var p1 = list.refresh().then(checkResult)
patternList['/some/*.js'].push('/some/c.js')
mg.statCache['/some/c.js'] = {mtime: new Date()}
mg.statCache['/some/c.js'] = {mtime: new Date(Date.now() + 5000)}
var p2 = list.refresh().then(checkResult)
var called = false
var callback = (data) => {
expect(called).to.be.false
expect(data.served[0].mtime.toString()).to.not.equal(data.served[2].mtime.toString())
expect(data.served[0].mtime.toString()).to.equal(data.served[1].mtime.toString())
called = true
}
list._emitter.on('file_list_modified', callback)

return Promise.all([p1, p2])
return Promise.all([p1, p2]).then(() => {
list._emitter.removeListener('file_list_modified', callback)
})
})

it('sets the mtime for all files', () => {
Expand Down

0 comments on commit 2df7811

Please sign in to comment.