Skip to content
This repository has been archived by the owner on Feb 4, 2018. It is now read-only.

catch http errors downloading github repos #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 21 additions & 5 deletions lib/sources/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,30 @@ var fetchTarball = function (source, dir, callback) {
var options = { url: source.url + '/tarball/' + branch, headers: headers }

request(options)
.pipe(gunzip())
.pipe(tar.Extract({ path: dir, strip: 1 }))
.on('response', function (resp) {
if (resp.statusCode >= 400) {
var err = new Error([
'Fetching',
options.url,
'failed:',
resp.statusCode,
resp.statusMessage,
].join(' '));
return callback(err);
}
resp
.pipe(gunzip())
.pipe(tar.Extract({ path: dir, strip: 1 }))
.on('error', function (err) {
return callback(err)
})
.on('end', function () {
callback(null, dir)
})
})
.on('error', function (err) {
return callback(err)
})
.on('end', function () {
callback(null, dir)
})
}

var fetchSource = function (source, dir, next) {
Expand Down