细节优化
This commit is contained in:
parent
cdf02345bd
commit
6e515e3d15
|
@ -1,6 +1,7 @@
|
||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
import fs from "node:fs"
|
import fs from "node:fs"
|
||||||
import path from "node:path"
|
import path from "node:path"
|
||||||
|
import common from "../common/common.js"
|
||||||
import { fileTypeFromBuffer } from "file-type"
|
import { fileTypeFromBuffer } from "file-type"
|
||||||
|
|
||||||
Bot.adapter.push(new class stdinAdapter {
|
Bot.adapter.push(new class stdinAdapter {
|
||||||
|
@ -8,8 +9,7 @@ Bot.adapter.push(new class stdinAdapter {
|
||||||
this.id = "stdin"
|
this.id = "stdin"
|
||||||
this.name = "标准输入"
|
this.name = "标准输入"
|
||||||
this.path = "data/stdin/"
|
this.path = "data/stdin/"
|
||||||
if (!fs.existsSync(this.path))
|
common.mkdirs(this.path)
|
||||||
fs.mkdirSync(this.path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async makeBuffer(file) {
|
async makeBuffer(file) {
|
||||||
|
|
|
@ -79,15 +79,12 @@ export class install extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async runInstall(name, url, path) {
|
async runInstall(name, url, path) {
|
||||||
this.isNowUp = false
|
|
||||||
|
|
||||||
let cm = `git clone --depth 1 --single-branch "${url}" "${path}"`
|
|
||||||
|
|
||||||
logger.mark(`${this.e.logFnc} 开始安装:${name} 插件`)
|
logger.mark(`${this.e.logFnc} 开始安装:${name} 插件`)
|
||||||
|
await this.reply(`开始安装 ${name} 插件`)
|
||||||
|
|
||||||
await this.reply(`开始安装:${name} 插件`)
|
const cm = `git clone --depth 1 --single-branch "${url}" "${path}"`
|
||||||
insing = true
|
insing = true
|
||||||
let ret = await this.execSync(cm)
|
const ret = await this.execSync(cm)
|
||||||
if (fs.existsSync(`${path}/package.json`))
|
if (fs.existsSync(`${path}/package.json`))
|
||||||
await this.execSync("pnpm install")
|
await this.execSync("pnpm install")
|
||||||
insing = false
|
insing = false
|
||||||
|
@ -97,8 +94,6 @@ export class install extends plugin {
|
||||||
this.gitErr(ret.error, ret.stdout)
|
this.gitErr(ret.error, ret.stdout)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async gitErr(err, stdout) {
|
async gitErr(err, stdout) {
|
||||||
|
@ -106,16 +101,14 @@ export class install extends plugin {
|
||||||
let errMsg = err.toString()
|
let errMsg = err.toString()
|
||||||
stdout = stdout.toString()
|
stdout = stdout.toString()
|
||||||
|
|
||||||
if (errMsg.includes("Timed out")) {
|
if (errMsg.includes('Timed out')) {
|
||||||
let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, "")
|
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
||||||
await this.reply(msg + `\n连接超时:${remote}`)
|
return this.reply(`${msg}\n连接超时:${remote}`)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/Failed to connect|unable to access/g.test(errMsg)) {
|
if (/Failed to connect|unable to access/g.test(errMsg)) {
|
||||||
let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, "")
|
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
|
||||||
await this.reply(msg + `\n连接失败:${remote}`)
|
return this.reply(`${msg}\n连接失败:${remote}`)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.reply([errMsg, stdout])
|
await this.reply([errMsg, stdout])
|
||||||
|
|
Loading…
Reference in New Issue