Skip to content

Commit

Permalink
dependencies: Set tough-cookie as optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Oct 15, 2013
1 parent bcc138d commit 8bfa640
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

var Cookie = require('tough-cookie')
, CookieJar = Cookie.CookieJar
, cookieJar = new CookieJar
var optional = require('./lib/optional')
, Cookie = optional('tough-cookie')
, CookieJar = Cookie && Cookie.CookieJar
, cookieJar = CookieJar && new CookieJar

, copy = require('./lib/copy')
, Request = require('./request')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"qs": "~0.6.0",
"json-stringify-safe": "~5.0.0",
"forever-agent": "~0.5.0",
"tough-cookie": "~0.9.15",
"node-uuid": "~1.4.0",
"mime": "~1.2.9"
},
"optionalDependencies": {
"tough-cookie": "~0.9.15",
"form-data": "~0.1.0",
"tunnel-agent": "~0.3.0",
"http-signature": "~0.10.0",
Expand Down
6 changes: 3 additions & 3 deletions request.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var optional = require('./lib/optional')
, ForeverAgent = require('forever-agent')
, FormData = optional('form-data')

, Cookie = require('tough-cookie')
, CookieJar = Cookie.CookieJar
, cookieJar = new CookieJar
, Cookie = optional('tough-cookie')
, CookieJar = Cookie && Cookie.CookieJar
, cookieJar = CookieJar && new CookieJar

, copy = require('./lib/copy')
, debug = require('./lib/debug')
Expand Down
8 changes: 8 additions & 0 deletions tests/test-follow-all.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
try {
require('tough-cookie')
} catch (e) {
console.error('tough-cookie must be installed to run this test.')
console.error('skipping this test. please install tough-cookie and run again if you need to test this feature.')
process.exit(0)
}

var request = require('../index');
var http = require('http');
var requests = 0;
Expand Down
8 changes: 8 additions & 0 deletions tests/test-headers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
try {
require('tough-cookie')
} catch (e) {
console.error('tough-cookie must be installed to run this test.')
console.error('skipping this test. please install tough-cookie and run again if you need to test this feature.')
process.exit(0)
}

var server = require('./server')
, assert = require('assert')
, request = require('../index')
Expand Down
8 changes: 8 additions & 0 deletions tests/test-redirect.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
try {
require('tough-cookie')
} catch (e) {
console.error('tough-cookie must be installed to run this test.')
console.error('skipping this test. please install tough-cookie and run again if you need to test this feature.')
process.exit(0)
}

var server = require('./server')
, assert = require('assert')
, request = require('../index')
Expand Down

0 comments on commit 8bfa640

Please sign in to comment.