fix: restart error

This commit is contained in:
ikechan8370 2023-02-20 13:40:17 +08:00
parent fcc1bd7972
commit b4c10d5c77
2 changed files with 12 additions and 3 deletions

View file

@ -2,7 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js'
import { Config } from '../utils/config.js' import { Config } from '../utils/config.js'
import { BingAIClient } from '@waylaidwanderer/chatgpt-api' import { BingAIClient } from '@waylaidwanderer/chatgpt-api'
import { exec } from 'child_process' import { exec } from 'child_process'
import {checkPnpm} from "../utils/common.js"; import { checkPnpm } from '../utils/common.js'
export class ChatgptManagement extends plugin { export class ChatgptManagement extends plugin {
constructor (e) { constructor (e) {

View file

@ -1,5 +1,6 @@
// import { remark } from 'remark' // import { remark } from 'remark'
// import stripMarkdown from 'strip-markdown' // import stripMarkdown from 'strip-markdown'
import { exec } from 'child_process'
// export function markdownToText (markdown) { // export function markdownToText (markdown) {
// return remark() // return remark()
// .use(stripMarkdown) // .use(stripMarkdown)
@ -183,7 +184,15 @@ function getDOMException (errorMessage) {
export async function checkPnpm () { export async function checkPnpm () {
let npm = 'npm' let npm = 'npm'
let ret = await this.execSync('pnpm -v') let ret = await execSync('pnpm -v')
if (ret.stdout) npm = 'pnpm' if (ret.stdout) npm = 'pnpm'
return npm return npm
} }
async function execSync (cmd) {
return new Promise((resolve, reject) => {
exec(cmd, { windowsHide: true }, (error, stdout, stderr) => {
resolve({ error, stdout, stderr })
})
})
}