Skip to content

Commit

Permalink
Merge pull request #1358 from zckrs/got-instead-request
Browse files Browse the repository at this point in the history
Replace "request" by "got"
  • Loading branch information
xzyfer committed Jan 27, 2016
2 parents 60af985 + c2d24c2 commit 92811c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"gaze": "^0.5.1",
"get-stdin": "^4.0.1",
"glob": "^6.0.2",
"got": "^5.4.1",
"meow": "^3.3.0",
"mkdirp": "^0.5.1",
"nan": "^2.0.8",
"node-gyp": "^3.0.1",
"npmconf": "^2.1.2",
"request": "^2.61.0",
"sass-graph": "^2.0.1"
},
"devDependencies": {
Expand Down
26 changes: 9 additions & 17 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var fs = require('fs'),
mkdir = require('mkdirp'),
npmconf = require('npmconf'),
path = require('path'),
request = require('request'),
got = require('got'),
pkg = require('../package.json');

require('../lib/extensions');
Expand All @@ -31,9 +31,6 @@ function download(url, dest, cb) {
'or configure npm proxy via', eol, eol,
' npm config set proxy http://example.com:8080'].join(''));
};
var successful = function(response) {
return response.statusCode >= 200 && response.statusCode < 300;
};

applyProxy({ rejectUnauthorized: false }, function(options) {
options.headers = {
Expand All @@ -43,19 +40,14 @@ function download(url, dest, cb) {
].join('')
};
try {
request(url, options, function(err, response) {
if (err) {
reportError(err);
} else if (!successful(response)) {
reportError(['HTTP error', response.statusCode, response.statusMessage].join(' '));
} else {
cb();
}
}).on('response', function(response) {
if (successful(response)) {
response.pipe(fs.createWriteStream(dest));
}
});
got.stream(url, options)
.on('error', function(error) {
reportError(error);
})
.on('end', function() {
cb();
})
.pipe(fs.createWriteStream(dest));
} catch (err) {
cb(err);
}
Expand Down

0 comments on commit 92811c6

Please sign in to comment.