Skip to content

Commit

Permalink
Support http_proxy, https_proxy in gulp git tasks (#1158)
Browse files Browse the repository at this point in the history
Co-authored-by: Damian Reeves <[email protected]>
  • Loading branch information
kmudrick and DamianReeves authored Apr 16, 2024
1 parent 5cc299c commit 47b92e4
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 36 deletions.
13 changes: 12 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const util = require('util')
const fs = require('fs')
const tmp = require('tmp')
const git = require('isomorphic-git')
const http = require('isomorphic-git/http/node')
const { request: delegate } = require('isomorphic-git/http/node')
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent')
const del = require('del')
const elmMake = require('node-elm-compiler').compile
const execa = require('execa');
Expand All @@ -18,6 +19,16 @@ const mainTsProject = ts.createProject('./tsconfig.json')
const cliTsProject = ts.createProject('./cli2/tsconfig.json')
const readFile = util.promisify(fs.readFile)

async function request ({ url, method, headers, body }) {
const proxy = url.startsWith('https:')
? { Agent: HttpsProxyAgent, url: process.env.https_proxy }
: { Agent: HttpProxyAgent, url: process.env.http_proxy }
const agent = proxy.url ? new proxy.Agent({ proxy: proxy.url }) : undefined
return delegate({ url, method, agent, headers, body })
}

const http = { request };

const config = {
morphirJvmVersion: '0.18.2',
morphirJvmCloneDir: tmp.dirSync()
Expand Down
101 changes: 67 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"gulp-concat": "^2.6.1",
"gulp-mocha": "^8.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"isomorphic-git": "^1.8.1",
"hpagent": "^1.2.0",
"isomorphic-git": "^1.25.7",
"jest": "^27.5.1",
"json-schema": "^0.4.0",
"mocha": "^9.1.3",
Expand Down

0 comments on commit 47b92e4

Please sign in to comment.