Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dependencies): update bluebird v.3 #1904

Merged
merged 2 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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