mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
fix kernelsu.spawn && add type definitions (#1395)
This commit is contained in:
parent
afe0e691aa
commit
2fb5334ac6
45
js/index.d.ts
vendored
Normal file
45
js/index.d.ts
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
interface ExecOptions {
|
||||
cwd?: string,
|
||||
env?: { [key: string]: string }
|
||||
}
|
||||
|
||||
interface ExecResults {
|
||||
errno: number,
|
||||
stdout: string,
|
||||
stderr: string
|
||||
}
|
||||
|
||||
declare function exec(command: string): Promise<ExecResults>;
|
||||
declare function exec(command: string, options: ExecOptions): Promise<ExecResults>;
|
||||
|
||||
interface SpawnOptions {
|
||||
cwd?: string,
|
||||
env?: { [key: string]: string }
|
||||
}
|
||||
|
||||
interface Stdio {
|
||||
on(event: 'data', callback: (data: string) => void)
|
||||
}
|
||||
|
||||
interface ChildProcess {
|
||||
stdout: Stdio,
|
||||
stderr: Stdio,
|
||||
on(event: 'exit', callback: (code: number) => void)
|
||||
on(event: 'error', callback: (err: any) => void)
|
||||
}
|
||||
|
||||
declare function spawn(command: string): ChildProcess;
|
||||
declare function spawn(command: string, args: string[]): ChildProcess;
|
||||
declare function spawn(command: string, options: SpawnOptions): ChildProcess;
|
||||
declare function spawn(command: string, args: string[], options: SpawnOptions): ChildProcess;
|
||||
|
||||
declare function fullScreen(isFullScreen: boolean);
|
||||
|
||||
declare function toast(message: string);
|
||||
|
||||
export {
|
||||
exec,
|
||||
spawn,
|
||||
fullScreen,
|
||||
toast
|
||||
}
|
@ -71,7 +71,7 @@ function Stdio() {
|
||||
export function spawn(command, args, options) {
|
||||
if (typeof args === "undefined") {
|
||||
args = [];
|
||||
} else if (typeof args === "object") {
|
||||
} else if (!(args instanceof Array)) {
|
||||
// allow for (command, options) signature
|
||||
options = args;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user