diff --git a/apps/management.js b/apps/management.js index 4c31a91..f5bab80 100644 --- a/apps/management.js +++ b/apps/management.js @@ -2,7 +2,7 @@ import plugin from '../../../lib/plugins/plugin.js' import { Config } from '../utils/config.js' import { BingAIClient } from '@waylaidwanderer/chatgpt-api' import { exec } from 'child_process' -import {checkPnpm} from "../utils/common.js"; +import { checkPnpm } from '../utils/common.js' export class ChatgptManagement extends plugin { constructor (e) { diff --git a/utils/common.js b/utils/common.js index bd72840..07794f3 100644 --- a/utils/common.js +++ b/utils/common.js @@ -1,5 +1,6 @@ // import { remark } from 'remark' // import stripMarkdown from 'strip-markdown' +import { exec } from 'child_process' // export function markdownToText (markdown) { // return remark() // .use(stripMarkdown) @@ -183,7 +184,15 @@ function getDOMException (errorMessage) { export async function checkPnpm () { let npm = 'npm' - let ret = await this.execSync('pnpm -v') + let ret = await execSync('pnpm -v') if (ret.stdout) npm = 'pnpm' return npm -} \ No newline at end of file +} + +async function execSync (cmd) { + return new Promise((resolve, reject) => { + exec(cmd, { windowsHide: true }, (error, stdout, stderr) => { + resolve({ error, stdout, stderr }) + }) + }) +}