Skip to content

Commit

Permalink
fix(contentful-export): Use http(s)agent instead of proxy (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaledgarbaya committed Jun 22, 2017
1 parent c0e6bbf commit f3cb6a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"presets": [
["env", {
"debug": true,
"targets": {
"node": 4.7
"node": "4.7"
}
}]
],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.gitignore.io/api/node,windows,osx,linux,vim
yarn.lock
package-lock.json
10 changes: 10 additions & 0 deletions lib/parseOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import fs from 'fs'
import { resolve } from 'path'
import { version } from '../package'
import { proxyStringToObject } from './utils/proxy'
import HttpsProxyAgent from 'https-proxy-agent'
import HttpProxyAgent from 'http-proxy-agent'

export default function parseOptions (params) {
const defaultOptions = {
Expand Down Expand Up @@ -65,6 +67,14 @@ export default function parseOptions (params) {
options.proxy = proxyStringToObject(options.proxy)
}

if (options.proxy && options.proxy.isHttps) {
options.httpsAgent = new HttpsProxyAgent(options.proxy)
delete options.proxy
} else if (options.proxy && !options.proxy.isHttps) {
options.httpAgent = new HttpProxyAgent(options.proxy)
delete options.proxy
}

options.managementApplication = options.managementApplication || `contentful.import/${version}`
return options
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
"dependencies": {
"bluebird": "^3.3.3",
"cli-table2": "^0.2.0",
"contentful-batch-libs": "^5.9.3",
"contentful-batch-libs": "^5.10.0",
"http-proxy-agent": "^1.0.0",
"https-proxy-agent": "^1.0.0",
"json-stringify-safe": "^5.0.1",
"lodash": "^4.0.0",
"moment": "^2.18.1",
Expand Down

0 comments on commit f3cb6a6

Please sign in to comment.