Skip to content

Commit

Permalink
Fix scope for function
Browse files Browse the repository at this point in the history
  • Loading branch information
guifromrio committed Dec 9, 2013
1 parent d2edb56 commit 641c092
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions libs/version-map.js
Expand Up @@ -115,7 +115,8 @@


VersionMap.prototype.downloadRegistryIndex = function() {
var deferred, req, timeoutCallback, timeoutMillis;
var deferred, req, timeoutCallback, timeoutMillis,
_this = this;
deferred = Q.defer();
req = this.s3Client.get(this.registryIndexPath);
timeoutMillis = 1000 * 30;
Expand All @@ -129,14 +130,14 @@
});
req.on("response", function(res) {
if (res.statusCode === 404) {
console.warn("No such registry index file available: " + this.registryIndexPath + ". Creating one now.");
console.warn("No such registry index file available: " + _this.registryIndexPath + ". Creating one now.");
return deferred.resolve("{}");
} else if (res.statusCode === 200) {
return res.on('data', function(chunk) {
return deferred.resolve(chunk);
});
} else {
return deferred.reject(new Error("Failed to download registry index at " + this.registryIndexPath + ". Status: " + res.statusCode));
return deferred.reject(new Error("Failed to download registry index at " + _this.registryIndexPath + ". Status: " + res.statusCode));
}
});
req.end();
Expand Down
2 changes: 1 addition & 1 deletion src/version-map.coffee
Expand Up @@ -102,7 +102,7 @@ class VersionMap
req.on "error", (err) ->
deferred.reject err

req.on "response", (res) ->
req.on "response", (res) =>
if res.statusCode is 404
console.warn "No such registry index file available: #{@registryIndexPath}. Creating one now."
deferred.resolve "{}"
Expand Down

0 comments on commit 641c092

Please sign in to comment.