mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 17:59:50 +02:00
chore: integrate ESLint
This commit is contained in:
parent
8bcd0ab913
commit
aa033e4de6
177 changed files with 5604 additions and 3798 deletions
|
@ -1,7 +1,13 @@
|
|||
import { GatherStringStream, DecodeUtf8Stream } from '@yume-chan/stream-extra';
|
||||
import { DecodeUtf8Stream, GatherStringStream } from "@yume-chan/stream-extra";
|
||||
|
||||
import { AdbCommandBase } from '../base.js';
|
||||
import { AdbSubprocessNoneProtocol, AdbSubprocessProtocol, AdbSubprocessProtocolConstructor, AdbSubprocessShellProtocol } from './protocols/index.js';
|
||||
import { AdbCommandBase } from "../base.js";
|
||||
|
||||
import {
|
||||
AdbSubprocessNoneProtocol,
|
||||
AdbSubprocessShellProtocol,
|
||||
type AdbSubprocessProtocol,
|
||||
type AdbSubprocessProtocolConstructor,
|
||||
} from "./protocols/index.js";
|
||||
|
||||
export interface AdbSubprocessOptions {
|
||||
/**
|
||||
|
@ -30,7 +36,7 @@ export interface AdbSubprocessWaitResult {
|
|||
|
||||
export class AdbSubprocess extends AdbCommandBase {
|
||||
private async createProtocol(
|
||||
mode: 'pty' | 'raw',
|
||||
mode: "pty" | "raw",
|
||||
command?: string | string[],
|
||||
options?: Partial<AdbSubprocessOptions>
|
||||
): Promise<AdbSubprocessProtocol> {
|
||||
|
@ -46,14 +52,14 @@ export class AdbSubprocess extends AdbCommandBase {
|
|||
}
|
||||
|
||||
if (!Constructor) {
|
||||
throw new Error('No specified protocol is supported by the device');
|
||||
throw new Error("No specified protocol is supported by the device");
|
||||
}
|
||||
|
||||
if (Array.isArray(command)) {
|
||||
command = command.join(' ');
|
||||
command = command.join(" ");
|
||||
} else if (command === undefined) {
|
||||
// spawn the default shell
|
||||
command = '';
|
||||
command = "";
|
||||
}
|
||||
return await Constructor[mode](this.adb, command);
|
||||
}
|
||||
|
@ -68,7 +74,7 @@ export class AdbSubprocess extends AdbCommandBase {
|
|||
command?: string | string[],
|
||||
options?: Partial<AdbSubprocessOptions>
|
||||
): Promise<AdbSubprocessProtocol> {
|
||||
return this.createProtocol('pty', command, options);
|
||||
return this.createProtocol("pty", command, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +87,7 @@ export class AdbSubprocess extends AdbCommandBase {
|
|||
command: string | string[],
|
||||
options?: Partial<AdbSubprocessOptions>
|
||||
): Promise<AdbSubprocessProtocol> {
|
||||
return this.createProtocol('raw', command, options);
|
||||
return this.createProtocol("raw", command, options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,13 +106,9 @@ export class AdbSubprocess extends AdbCommandBase {
|
|||
const stderr = new GatherStringStream();
|
||||
|
||||
const [, , exitCode] = await Promise.all([
|
||||
shell.stdout
|
||||
.pipeThrough(new DecodeUtf8Stream())
|
||||
.pipeTo(stdout),
|
||||
shell.stderr
|
||||
.pipeThrough(new DecodeUtf8Stream())
|
||||
.pipeTo(stderr),
|
||||
shell.exit
|
||||
shell.stdout.pipeThrough(new DecodeUtf8Stream()).pipeTo(stdout),
|
||||
shell.stderr.pipeThrough(new DecodeUtf8Stream()).pipeTo(stderr),
|
||||
shell.exit,
|
||||
]);
|
||||
|
||||
return {
|
||||
|
@ -121,11 +123,12 @@ export class AdbSubprocess extends AdbCommandBase {
|
|||
* @param command The command to run
|
||||
* @returns The entire output of the command
|
||||
*/
|
||||
public async spawnAndWaitLegacy(command: string | string[]): Promise<string> {
|
||||
const { stdout } = await this.spawnAndWait(
|
||||
command,
|
||||
{ protocols: [AdbSubprocessNoneProtocol] }
|
||||
);
|
||||
public async spawnAndWaitLegacy(
|
||||
command: string | string[]
|
||||
): Promise<string> {
|
||||
const { stdout } = await this.spawnAndWait(command, {
|
||||
protocols: [AdbSubprocessNoneProtocol],
|
||||
});
|
||||
return stdout;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue