refactor: mirrors
parent
aa4f029f62
commit
9b831d3322
|
@ -14,7 +14,7 @@
|
|||
### 3、 github的源代码查看(raw/blame查看)
|
||||
通过跳转到国内加速链接上
|
||||
### 4、 Stack Overflow 加速
|
||||
将ajax.google.com代理到加速代理上
|
||||
将ajax.google.com代理到加速代理上 ,recaptcha 加速
|
||||
### 5、 google cdn 加速
|
||||
通过代理到加速链接上
|
||||
|
||||
|
|
|
@ -34,11 +34,13 @@ const configApi = {
|
|||
resetDefault () {
|
||||
configTarget = lodash.cloneDeep(defConfig)
|
||||
},
|
||||
getMirrorEnv () {
|
||||
const envMap = Shell.getEnv()
|
||||
async getMirrorEnv () {
|
||||
const envMap = await Shell.getEnv()
|
||||
const list = []
|
||||
const mirrors = configTarget.mirrors
|
||||
console.log('envMap', envMap)
|
||||
for (const key in mirrors) {
|
||||
console.log('equale', key, envMap[key])
|
||||
const exists = envMap[key] != null
|
||||
list.push({
|
||||
key,
|
||||
|
@ -49,14 +51,14 @@ const configApi = {
|
|||
console.log('mirrors:', list)
|
||||
return list
|
||||
},
|
||||
setupMirrors () {
|
||||
const list = configApi.getMirrorEnv()
|
||||
async setupMirrors () {
|
||||
const list = await configApi.getMirrorEnv()
|
||||
const noSetList = list.filter(item => {
|
||||
return !item.exists
|
||||
})
|
||||
console.log('mirrors will set:', noSetList)
|
||||
if (list.length > 0) {
|
||||
Shell.setEnv({ list: noSetList })
|
||||
return Shell.setEnv({ list: noSetList })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const expose = require('./expose.js')
|
||||
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||||
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
||||
|
||||
// 避免异常崩溃
|
||||
process.on('uncaughtException', function (err) {
|
||||
|
|
|
@ -12,7 +12,7 @@ const executor = {
|
|||
for (const item of lines) {
|
||||
const kv = item.split('=')
|
||||
if (kv.length > 1) {
|
||||
map[kv[0]] = kv[1]
|
||||
map[kv[0].trim()] = kv[1].trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ const executor = {
|
|||
const cmds = []
|
||||
for (const item of list) {
|
||||
// [Environment]::SetEnvironmentVariable('FOO', 'bar', 'Machine')
|
||||
cmds.push(`[Environment]::SetEnvironmentVariable('${item.key} ', '${item.value}', 'Machine')`)
|
||||
cmds.push(`[Environment]::SetEnvironmentVariable('${item.key}', '${item.value}', 'Machine')`)
|
||||
}
|
||||
const ret = await exec(cmds, { type: 'ps' })
|
||||
return ret
|
||||
|
|
Loading…
Reference in New Issue