const {exec} = require("child_process");
const regexDevices = /[a-zA-Z0-9]/g
exec("adb devices ", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.log(`stderr: ${stderr}`);
        return;
    }
    console.log(`stdout: ${stdout}`);
//     find the device id from output
//     let matchedDeviceIds  = regexDevices.exec(stdout)
    regexDevices.global = true
    let matchedDeviceIds = stdout.matchAll(regexDevices);
    for (m in matchedDeviceIds) {
        console.log(m);
    }
    console.log(matchedDeviceIds)
    // var m;
    // do {
    // let m = regexDevices.exec(stdout);
    // if (m) {
    //     console.log(m[1], m[2]);
    // }
    // } while (m);
});