Skip to content

Commit

Permalink
Merge pull request #1904 from BridgeAR/master
Browse files Browse the repository at this point in the history
chore(dependencies): update bluebird v.3
  • Loading branch information
dignifiedquire committed Feb 18, 2016
2 parents e81c3c7 + af0bc5b commit e4b640a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
22 changes: 9 additions & 13 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.all(this._patterns.map(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 @@ -195,17 +195,17 @@ List.prototype._refresh = function () {
buckets.set(pattern, new Set(files))
}
})
}))
.cancellable()
})
.then(function () {
if (self._refreshing !== promise) {
return self._refreshing
}
self.buckets = buckets
self._emitModified(true)
return self.files
})
.catch(Promise.CancellationError, function () {
// We were canceled so return the resolution of the new run
return self._refreshing
})

return promise
}

// Public Interface
Expand Down Expand Up @@ -245,10 +245,6 @@ Object.defineProperty(List.prototype, 'files', {
// Returns a promise that is resolved when the refresh
// is completed.
List.prototype.refresh = function () {
if (this._isRefreshing()) {
this._refreshing.cancel()
}

this._refreshing = this._refresh()
return this._refreshing
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
],
"dependencies": {
"batch": "^0.5.3",
"bluebird": "^2.9.27",
"bluebird": "^3.3.0",
"body-parser": "^1.12.4",
"chokidar": "^1.4.1",
"colors": "^1.1.0",
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 e4b640a

Please sign in to comment.