From 39773f7a724994cdbb6195e9ec0b0a0198205932 Mon Sep 17 00:00:00 2001 From: seanstrom Date: Wed, 15 Oct 2014 16:15:06 -0700 Subject: [PATCH 1/3] remove optional dependencies --- .travis.yml | 7 +------ lib/cookies.js | 3 +-- lib/optional.js | 15 --------------- package.json | 4 +--- request.js | 17 ++++++++--------- tests/test-optional.js | 9 --------- 6 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 lib/optional.js delete mode 100644 tests/test-optional.js diff --git a/.travis.yml b/.travis.yml index 6e4887af8..9edc6d9dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,4 @@ node_js: - "0.10" env: - - OPTIONALS=Y - - OPTIONALS=N - -install: - - if [[ "$OPTIONALS" == "Y" ]]; then npm install; fi - - if [[ "$OPTIONALS" == "N" ]]; then npm install --no-optional; fi + npm install; diff --git a/lib/cookies.js b/lib/cookies.js index af2489ae8..541c5720b 100644 --- a/lib/cookies.js +++ b/lib/cookies.js @@ -1,7 +1,6 @@ 'use strict' -var optional = require('./optional') - , tough = optional('tough-cookie') +var tough = require('tough-cookie') , Cookie = tough && tough.Cookie , CookieJar = tough && tough.CookieJar diff --git a/lib/optional.js b/lib/optional.js deleted file mode 100644 index d867646b6..000000000 --- a/lib/optional.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict' - -module.exports = function(moduleName) { - try { - return module.parent.require(moduleName) - } catch (e) { - // This could mean that we are in a browser context. - // Add another try catch like it used to be, for backwards compability - // and browserify reasons. - try { - return require(moduleName) - } - catch (e) {} - } -} diff --git a/package.json b/package.json index 88b6858d1..58bb4ff4d 100755 --- a/package.json +++ b/package.json @@ -30,9 +30,7 @@ "mime-types": "~1.0.1", "node-uuid": "~1.4.0", "qs": "~1.2.0", - "tunnel-agent": "~0.4.0" - }, - "optionalDependencies": { + "tunnel-agent": "~0.4.0", "tough-cookie": ">=0.12.0", "http-signature": "~0.10.0", "oauth-sign": "~0.4.0", diff --git a/request.js b/request.js index 647f54660..4644aea8d 100644 --- a/request.js +++ b/request.js @@ -1,8 +1,7 @@ 'use strict' -var optional = require('./lib/optional') - , http = require('http') - , https = optional('https') +var http = require('http') + , https = require('https') , url = require('url') , util = require('util') , stream = require('stream') @@ -16,18 +15,18 @@ var optional = require('./lib/optional') , toBase64 = helpers.toBase64 , defer = helpers.defer , bl = require('bl') - , oauth = optional('oauth-sign') - , hawk = optional('hawk') - , aws = optional('aws-sign2') - , httpSignature = optional('http-signature') + , oauth = require('oauth-sign') + , hawk = require('hawk') + , aws = require('aws-sign2') + , httpSignature = require('http-signature') , uuid = require('node-uuid') , mime = require('mime-types') , tunnel = require('tunnel-agent') - , stringstream = optional('stringstream') + , stringstream = require('stringstream') , caseless = require('caseless') , ForeverAgent = require('forever-agent') - , FormData = optional('form-data') + , FormData = require('form-data') , cookies = require('./lib/cookies') , globalCookieJar = cookies.jar() diff --git a/tests/test-optional.js b/tests/test-optional.js deleted file mode 100644 index 46fe2126e..000000000 --- a/tests/test-optional.js +++ /dev/null @@ -1,9 +0,0 @@ -var optional = require('../lib/optional') - , copy = optional('../lib/copy') - , tape = require('tape') - -tape('optional modules show as being loaded by the module that requested them', function(t) { - t.equal(module.children[1].exports, copy) - t.equal(module, module.children[1].parent) - t.end() -}) From 8fa5afae534526a1197cc283722032d0fbc5c3d4 Mon Sep 17 00:00:00 2001 From: seanstrom Date: Wed, 15 Oct 2014 18:43:47 -0700 Subject: [PATCH 2/3] remove optional requires in tests --- tests/test-cookies.js | 8 -------- tests/test-follow-all.js | 8 -------- tests/test-gzip.js | 10 ---------- tests/test-hawk.js | 8 -------- tests/test-headers.js | 8 -------- tests/test-http-signature.js | 8 -------- tests/test-oauth.js | 8 -------- tests/test-redirect.js | 8 -------- 8 files changed, 66 deletions(-) diff --git a/tests/test-cookies.js b/tests/test-cookies.js index fa5cebe5d..d6239e436 100644 --- a/tests/test-cookies.js +++ b/tests/test-cookies.js @@ -1,11 +1,3 @@ -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 http = require('http') , request = require('../index') , tape = require('tape') diff --git a/tests/test-follow-all.js b/tests/test-follow-all.js index 2a7dbe949..dfcedda97 100644 --- a/tests/test-follow-all.js +++ b/tests/test-follow-all.js @@ -1,11 +1,3 @@ -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 http = require('http') , request = require('../index') , tape = require('tape') diff --git a/tests/test-gzip.js b/tests/test-gzip.js index 45a226602..4cf28bc7b 100644 --- a/tests/test-gzip.js +++ b/tests/test-gzip.js @@ -3,16 +3,6 @@ var request = require('../index') , zlib = require('zlib') , tape = require('tape') -if (!zlib.Gunzip.prototype.setEncoding) { - try { - require('stringstream') - } catch (e) { - console.error('stringstream must be installed to run this test.') - console.error('skipping this test. please install stringstream and run again if you need to test this feature.') - process.exit(0) - } -} - var testContent = 'Compressible response content.\n' , testContentGzip diff --git a/tests/test-hawk.js b/tests/test-hawk.js index 99bc898b9..1d341fe9e 100644 --- a/tests/test-hawk.js +++ b/tests/test-hawk.js @@ -1,11 +1,3 @@ -try { - require('hawk') -} catch (e) { - console.error('hawk must be installed to run this test.') - console.error('skipping this test. please install hawk and run again if you need to test this feature.') - process.exit(0) -} - var http = require('http') , request = require('../index') , hawk = require('hawk') diff --git a/tests/test-headers.js b/tests/test-headers.js index 42e757eda..d28d455cc 100644 --- a/tests/test-headers.js +++ b/tests/test-headers.js @@ -1,11 +1,3 @@ -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') , request = require('../index') , tape = require('tape') diff --git a/tests/test-http-signature.js b/tests/test-http-signature.js index f6ec5716e..1c325e069 100644 --- a/tests/test-http-signature.js +++ b/tests/test-http-signature.js @@ -1,11 +1,3 @@ -try { - require('http-signature') -} catch (e) { - console.error('http-signature must be installed to run this test.') - console.error('skipping this test. please install http-signature and run again if you need to test this feature.') - process.exit(0) -} - var http = require('http') , request = require('../index') , httpSignature = require('http-signature') diff --git a/tests/test-oauth.js b/tests/test-oauth.js index ced28d6d2..bf5032867 100644 --- a/tests/test-oauth.js +++ b/tests/test-oauth.js @@ -1,11 +1,3 @@ -try { - require('oauth-sign') -} catch (e) { - console.error('oauth-sign must be installed to run this test.') - console.error('skipping this test. please install oauth-sign and run again if you need to test this feature.') - process.exit(0) -} - var hmacsign = require('oauth-sign').hmacsign , qs = require('querystring') , request = require('../index') diff --git a/tests/test-redirect.js b/tests/test-redirect.js index dda99c688..d67762a1e 100644 --- a/tests/test-redirect.js +++ b/tests/test-redirect.js @@ -1,11 +1,3 @@ -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') From be9a0765b921506e01b9badaa9c04c3759708afa Mon Sep 17 00:00:00 2001 From: seanstrom Date: Wed, 15 Oct 2014 18:44:00 -0700 Subject: [PATCH 3/3] remove env from travis.yml --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9edc6d9dc..cc4dba29d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,3 @@ language: node_js node_js: - "0.8" - "0.10" - -env: - npm install;