Update: 更新Shell

This commit is contained in:
王立帮
2024-12-02 22:55:53 +08:00
parent 5ea6082fbe
commit 3911fa27ac

View File

@@ -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 {