-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlist-applications.ts
25 lines (20 loc) · 1 KB
/
list-applications.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { EOL } from "os";
import * as util from "util";
export class ListApplicationsCommand implements ICommand {
constructor(private $devicesService: Mobile.IDevicesService,
private $logger: ILogger,
private $options: IOptions) { }
allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
await this.$devicesService.initialize({ deviceId: this.$options.device, skipInferPlatform: true });
const output: string[] = [];
const action = async (device: Mobile.IDevice) => {
const applications = await device.applicationManager.getInstalledApplications();
output.push(util.format("%s=====Installed applications on device with UDID '%s' are:", EOL, device.deviceInfo.identifier));
_.each(applications, (applicationId: string) => output.push(applicationId));
};
await this.$devicesService.execute(action);
this.$logger.info(output.join(EOL));
}
}
$injector.registerCommand(["device|list-applications", "devices|list-applications"], ListApplicationsCommand);