Skip to content

Commit

Permalink
wrap http.get on Node 8 only
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Kuba committed Jun 5, 2017
1 parent 5db4fa0 commit aac5c34
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var _ = require('lodash');
var debug = require('debug')('nock.common');
var semver = require('semver')

/**
* Normalizes the request options so that it always has `host` property.
Expand Down Expand Up @@ -139,10 +140,12 @@ var overrideRequests = function(newRequest) {
return newRequest(proto, overriddenRequest.bind(module), options, callback);
};

module.get = function(options, callback) {
var req = newRequest(proto, overriddenRequest.bind(module), options, callback);
req.end();
return req;
if (semver.satisfies(process.version, '>=8')) {
module.get = function(options, callback) {
var req = newRequest(proto, overriddenRequest.bind(module), options, callback);
req.end();
return req;
}
}

debug('- overridden request for', proto);
Expand Down

0 comments on commit aac5c34

Please sign in to comment.