mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 02:09:18 +02:00
feat(stream): improve ConcatStringStream
This commit is contained in:
parent
e3bfd1592f
commit
721e14fa7a
16 changed files with 380 additions and 72 deletions
|
@ -10,7 +10,7 @@ import {
|
|||
AdbSubprocessNoneProtocol,
|
||||
AdbSubprocessShellProtocol,
|
||||
} from "@yume-chan/adb";
|
||||
import { DecodeUtf8Stream, GatherStringStream } from "@yume-chan/stream-extra";
|
||||
import { ConcatStringStream, DecodeUtf8Stream } from "@yume-chan/stream-extra";
|
||||
|
||||
export class Cmd extends AdbCommandBase {
|
||||
#supportsShellV2: boolean;
|
||||
|
@ -82,18 +82,19 @@ export class Cmd extends AdbCommandBase {
|
|||
): Promise<AdbSubprocessWaitResult> {
|
||||
const process = await this.spawn(true, command, ...args);
|
||||
|
||||
const stdout = new GatherStringStream();
|
||||
const stderr = new GatherStringStream();
|
||||
|
||||
const [, , exitCode] = await Promise.all([
|
||||
process.stdout.pipeThrough(new DecodeUtf8Stream()).pipeTo(stdout),
|
||||
process.stderr.pipeThrough(new DecodeUtf8Stream()).pipeTo(stderr),
|
||||
const [stdout, stderr, exitCode] = await Promise.all([
|
||||
process.stdout
|
||||
.pipeThrough(new DecodeUtf8Stream())
|
||||
.pipeThrough(new ConcatStringStream()),
|
||||
process.stderr
|
||||
.pipeThrough(new DecodeUtf8Stream())
|
||||
.pipeThrough(new ConcatStringStream()),
|
||||
process.exit,
|
||||
]);
|
||||
|
||||
return {
|
||||
stdout: stdout.result,
|
||||
stderr: stderr.result,
|
||||
stdout,
|
||||
stderr,
|
||||
exitCode,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue