mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 17:59:50 +02:00
feat(bin): add PackageManager.prototype.getPackages
method
This commit is contained in:
parent
5a1f41766c
commit
0f29501c5f
2 changed files with 21 additions and 0 deletions
5
.changeset/forty-years-rule.md
Normal file
5
.changeset/forty-years-rule.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"@yume-chan/android-bin": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Add `PackageManager.prototype.getPackages` method to get apk paths
|
|
@ -475,6 +475,22 @@ export class PackageManager extends AdbCommandBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPackages(packageName: string): Promise<string[]> {
|
||||||
|
const args = ["pm", "-p", packageName];
|
||||||
|
|
||||||
|
const process = await this.#cmdOrSubprocess(args);
|
||||||
|
const result: string[] = [];
|
||||||
|
for await (const line of process.stdout
|
||||||
|
.pipeThrough(new TextDecoderStream())
|
||||||
|
.pipeThrough(new SplitStringStream("\n"))) {
|
||||||
|
if (line.startsWith("package:")) {
|
||||||
|
result.push(line.substring("package:".length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
async uninstall(
|
async uninstall(
|
||||||
packageName: string,
|
packageName: string,
|
||||||
options?: Partial<PackageManagerUninstallOptions>,
|
options?: Partial<PackageManagerUninstallOptions>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue