diff --git a/README.md b/README.md index b67b546c..e08e5e81 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ### 3、 github的源代码查看(raw/blame查看) 通过跳转到国内加速链接上 ### 4、 Stack Overflow 加速 -将ajax.google.com代理到加速代理上 +将ajax.google.com代理到加速代理上 ,recaptcha 加速 ### 5、 google cdn 加速 通过代理到加速链接上 diff --git a/packages/core/src/config.js b/packages/core/src/config.js index 9cf136f7..d4162e3e 100644 --- a/packages/core/src/config.js +++ b/packages/core/src/config.js @@ -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 }) } } } diff --git a/packages/core/src/index.js b/packages/core/src/index.js index a7ed7e58..4d385195 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -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) { diff --git a/packages/core/src/shell/scripts/get-env.js b/packages/core/src/shell/scripts/get-env.js index 81b7d601..849ffb75 100644 --- a/packages/core/src/shell/scripts/get-env.js +++ b/packages/core/src/shell/scripts/get-env.js @@ -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() } } } diff --git a/packages/core/src/shell/scripts/set-env.js b/packages/core/src/shell/scripts/set-env.js index f561f992..f157d7f0 100644 --- a/packages/core/src/shell/scripts/set-env.js +++ b/packages/core/src/shell/scripts/set-env.js @@ -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