From 6e515e3d15b6c98f152581d23d6ef5a63b7e3afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Thu, 27 Jul 2023 18:46:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/stdin.js | 4 ++-- plugins/other/install.js | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lib/plugins/stdin.js b/lib/plugins/stdin.js index 5886b73..e22a011 100644 --- a/lib/plugins/stdin.js +++ b/lib/plugins/stdin.js @@ -1,6 +1,7 @@ import fetch from "node-fetch" import fs from "node:fs" import path from "node:path" +import common from "../common/common.js" import { fileTypeFromBuffer } from "file-type" Bot.adapter.push(new class stdinAdapter { @@ -8,8 +9,7 @@ Bot.adapter.push(new class stdinAdapter { this.id = "stdin" this.name = "标准输入" this.path = "data/stdin/" - if (!fs.existsSync(this.path)) - fs.mkdirSync(this.path) + common.mkdirs(this.path) } async makeBuffer(file) { diff --git a/plugins/other/install.js b/plugins/other/install.js index 88f8d2b..3150ecd 100644 --- a/plugins/other/install.js +++ b/plugins/other/install.js @@ -79,15 +79,12 @@ export class install extends plugin { } async runInstall(name, url, path) { - this.isNowUp = false - - let cm = `git clone --depth 1 --single-branch "${url}" "${path}"` - 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 - let ret = await this.execSync(cm) + const ret = await this.execSync(cm) if (fs.existsSync(`${path}/package.json`)) await this.execSync("pnpm install") insing = false @@ -97,8 +94,6 @@ export class install extends plugin { this.gitErr(ret.error, ret.stdout) return false } - - return true } async gitErr(err, stdout) { @@ -106,16 +101,14 @@ export class install extends plugin { let errMsg = err.toString() stdout = stdout.toString() - if (errMsg.includes("Timed out")) { - let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, "") - await this.reply(msg + `\n连接超时:${remote}`) - return + if (errMsg.includes('Timed out')) { + const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '') + return this.reply(`${msg}\n连接超时:${remote}`) } if (/Failed to connect|unable to access/g.test(errMsg)) { - let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, "") - await this.reply(msg + `\n连接失败:${remote}`) - return + const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '') + return this.reply(`${msg}\n连接失败:${remote}`) } await this.reply([errMsg, stdout])