Skip to content

Commit

Permalink
Revert "Replace "request" by "got""
Browse files Browse the repository at this point in the history
This reverts commit c2d24c2.

Unfortunately got does not have good [proxy support][1] which
was missed during review.

Fixes sass#1458

[1]: sindresorhus/got#79
  • Loading branch information
xzyfer committed Apr 21, 2016
1 parent 44951fe commit 03beee5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
"gaze": "^1.0.0",
"get-stdin": "^4.0.1",
"glob": "^7.0.3",
"got": "^5.5.0",
"meow": "^3.7.0",
"in-publish": "^2.0.0",
"mkdirp": "^0.5.1",
"nan": "^2.2.0",
"node-gyp": "^3.3.1",
"npmconf": "^2.1.2",
"request": "^2.61.0",
"sass-graph": "^2.1.1"
},
"devDependencies": {
Expand Down
28 changes: 18 additions & 10 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var fs = require('fs'),
mkdir = require('mkdirp'),
npmconf = require('npmconf'),
path = require('path'),
got = require('got'),
pkg = require('../package.json'),
sass = require('../lib/extensions');
request = require('request'),
pkg = require('../package.json');

/**
* Download file, if succeeds save, if not delete
Expand All @@ -30,6 +30,9 @@ 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 @@ -39,14 +42,19 @@ function download(url, dest, cb) {
].join('')
};
try {
got.stream(url, options)
.on('error', function(error) {
reportError(error);
})
.on('end', function() {
cb();
})
.pipe(fs.createWriteStream(dest));
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));
}
});
} catch (err) {
cb(err);
}
Expand Down

0 comments on commit 03beee5

Please sign in to comment.