@u4/adbkit
Version:
A Typescript client for the Android Debug Bridge.
43 lines • 1.62 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __importDefault(require("../../command"));
const DeviceClient_1 = __importDefault(require("../../DeviceClient"));
const Device_1 = require("../../../models/Device");
class HostDevicesWithPathsCommand extends command_1.default {
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 (!(0, Device_1.isDeviceType)(type)) {
continue;
}
devices.push({
id,
type,
path,
product,
model,
device,
transportId,
getClient: () => new DeviceClient_1.default(this.connection.parent, id),
});
}
return devices;
}
}
exports.default = HostDevicesWithPathsCommand;
//# sourceMappingURL=HostDevicesWithPathsCommand.js.map