@u4/adbkit
Version:
A Typescript client for the Android Debug Bridge.
37 lines • 1.3 kB
JavaScript
import Command from '../../command.js';
import DeviceClient from '../../DeviceClient.js';
import { isDeviceType } from '../../../models/Device.js';
export default class HostDevicesWithPathsCommand extends Command {
async execute() {
await this._send('host:devices-l');
await this.readOKAY();
return this._readDevices();
}
async _readDevices() {
const value = await this.parser.readValue('ascii');
return this._parseDevices(value);
}
_parseDevices(value) {
const regexp = /^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+product:([^\s]+)\s+model:([^\s]+)\s+device:([^\s]+)\s+transport_id:([^\s]+)$/gm;
const devices = [];
let match;
while ((match = regexp.exec(value)) !== null) {
const [, id, type, path, product, model, device, transportId] = match;
if (!isDeviceType(type)) {
continue;
}
devices.push({
id,
type,
path,
product,
model,
device,
transportId,
getClient: () => new DeviceClient(this.connection.parent, id),
});
}
return devices;
}
}
//# sourceMappingURL=HostDevicesWithPathsCommand.js.map