linux first

pull/88/head
xiaojunnuo 2021-08-12 19:00:16 +08:00
parent 13d34a025b
commit e97269f5d6
5 changed files with 46 additions and 18 deletions

View File

@ -122,7 +122,17 @@ const executor = {
}
},
async linux (exec, params) {
throw Error('暂未实现此功能')
await exec('sudo sed -i \'/export https=/d\' ~/.bashrc')
await exec('sudo sed -i \'/export no_proxy=/d\' ~/.bashrc')
if (params != null) {
const { ip, port } = params
const local = 'localhost, 127.0.0.1, ::1'
const setProxyCmd = `sudo echo 'export https_proxy=https://${ip}:${port}' >> ~/.bashrc`
await exec(setProxyCmd)
await exec(`sudo echo 'export no_proxy="${local}"' >> ~/.bashrc`)
}
await exec('source ~/.bashrc')
},
async mac (exec, params) {
// exec = _exec

View File

@ -21,7 +21,7 @@ class LinuxSystemShell extends SystemShell {
cmds = [cmds]
}
for (const cmd of cmds) {
await childExec(cmd)
await _childExec(cmd, { shell: '/bin/bash' })
}
}
}
@ -33,7 +33,7 @@ class DarwinSystemShell extends SystemShell {
}
let ret
for (const cmd of cmds) {
ret = await childExec(cmd)
ret = await _childExec(cmd)
}
return ret
}
@ -76,13 +76,31 @@ class WindowsSystemShell extends SystemShell {
}
}
function _childExec (composeCmds, options = {}) {
return new Promise((resolve, reject) => {
const childProcess = require('child_process')
log.info('shell:', composeCmds)
childProcess.exec(composeCmds, options, function (error, stdout, stderr) {
if (error) {
log.error('cmd 命令执行错误:', composeCmds, stderr)
reject(new Error(stderr))
} else {
// log.info('cmd 命令完成:', stdout)
resolve(stdout)
}
// log.info('关闭 cmd')
// ps.kill('SIGINT')
})
})
}
function childExec (composeCmds) {
return new Promise((resolve, reject) => {
var encoding = 'cp936'
var binaryEncoding = 'binary'
const childProcess = require('child_process')
log.info('shell:', composeCmds)
childProcess.exec(composeCmds, { encoding: binaryEncoding }, function (error, stdout, stderr) {
if (error) {
// console.log('------', decoder.decode(stderr))

View File

@ -93,10 +93,10 @@
lodash "^4.17.19"
to-fast-properties "^2.0.0"
"@docmirror/mitmproxy@^1.5.0":
version "1.5.0"
resolved "https://registry.npmjs.org/@docmirror/mitmproxy/-/mitmproxy-1.5.0.tgz#16b9a956542a56f9889cd0c69c08a33d06d77ab8"
integrity sha512-H17TAqKmvzCMSTO6VGTC6kKQskjk1gEJZYsU2ijziZU0XEC96ObG0TWOnsdKh2PhmwDLwxS9cUyb1hpYilLreQ==
"@docmirror/mitmproxy@^1.5.1":
version "1.5.1"
resolved "https://registry.nlark.com/@docmirror/mitmproxy/download/@docmirror/mitmproxy-1.5.1.tgz#357142a41b89266491c3519a7528b9b83dc30c85"
integrity sha1-NXFCpBuJJmSRw1GadSi5uD3DDIU=
dependencies:
agentkeepalive "^2.1.1"
axios "^0.21.1"

View File

@ -45,7 +45,7 @@
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"babel-eslint": "^10.1.0",
"electron": "10.4.2",
"electron": "^13.1.9",
"electron-devtools-installer": "^3.1.0",
"electron-icon-builder": "^1.0.2",
"eslint": "^6.7.2",

View File

@ -1507,10 +1507,10 @@
resolved "https://registry.npm.taobao.org/@types/node/download/@types/node-14.11.8.tgz"
integrity sha1-/iAS8jVeTOCLykSus6u7Ic+I0z8=
"@types/node@^12.0.12":
version "12.20.6"
resolved "https://registry.npmjs.org/@types/node/-/node-12.20.6.tgz"
integrity sha512-sRVq8d+ApGslmkE9e3i+D3gFGk7aZHAT+G4cIpIEdLJYPsWiSPwcAnJEjddLQQDqV3Ra2jOclX/Sv6YrvGYiWA==
"@types/node@^14.6.2":
version "14.17.9"
resolved "https://registry.nlark.com/@types/node/download/@types/node-14.17.9.tgz?cache=0&sync_timestamp=1628719497956&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-14.17.9.tgz#b97c057e6138adb7b720df2bd0264b03c9f504fd"
integrity sha1-uXwFfmE4rbe3IN8r0CZLA8n1BP0=
"@types/normalize-package-data@^2.4.0":
version "2.4.0"
@ -4651,13 +4651,13 @@ electron-updater@^4.3.5:
lodash.isequal "^4.5.0"
semver "^7.3.2"
electron@10.4.2:
version "10.4.2"
resolved "https://registry.nlark.com/electron/download/electron-10.4.2.tgz?cache=0&sync_timestamp=1620442447118&other_urls=https%3A%2F%2Fregistry.nlark.com%2Felectron%2Fdownload%2Felectron-10.4.2.tgz#2322a72f1e653e023250be91f3dd8d27662e3805"
integrity sha1-IyKnLx5lPgIyUL6R892NJ2YuOAU=
electron@^13.1.9:
version "13.1.9"
resolved "https://registry.nlark.com/electron/download/electron-13.1.9.tgz#668e2632b81e9fa21edfd32876282d3e2ff7fd76"
integrity sha1-Zo4mMrgen6Ie39ModigtPi/3/XY=
dependencies:
"@electron/get" "^1.0.1"
"@types/node" "^12.0.12"
"@types/node" "^14.6.2"
extract-zip "^1.0.3"
elliptic@^6.5.3: