From 3911fa27ac1531021f93907ed7f01ed97a85b099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Mon, 2 Dec 2024 22:55:53 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=E6=9B=B4=E6=96=B0Shell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/shell.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/shell.js b/src/common/shell.js index c596368..a92b751 100644 --- a/src/common/shell.js +++ b/src/common/shell.js @@ -51,7 +51,7 @@ export default class Shell extends EventsBase { lines[i] = iconv_lite.decode(Buffer.from(lines[i], 'binary'), encoding); } data = lines.join('\n'); - // data = this.#decode_(data); + data = this.#decode_(data); this.runEvent('error', data); }); } @@ -74,6 +74,7 @@ export default class Shell extends EventsBase { } async exec(command, options = {}) { + this.#killed_ = false; this.#shell_ = exec(command, { ...this.#defaultOptions_, ...options }); this.#addEventsListener_(); const result = await this.#waitUntilClosed_(); @@ -81,6 +82,7 @@ export default class Shell extends EventsBase { } async execFile(file, args, options = {}) { + this.#killed_ = false; this.#shell_ = execFile(file, args, { ...this.#defaultOptions_, ...options }); this.#addEventsListener_(); const result = await this.#waitUntilClosed_(); @@ -95,7 +97,7 @@ export default class Shell extends EventsBase { this.#shell_.stdin.end(); this.#shell_.stdout.end(); if (CURRENT_PLANTFORM === 'win32') { - exec(`taskkill /pid ${this.#shell_.pid} /f /t`, (error) => { + exec(`taskkill /pid ${this.#shell_.pid} /f /t`, { encoding: 'utf-8' }, (error) => { if (error) { reject(error); } else {