All files / lib/extensions isolate-sim.js

50% Statements 3/6
100% Branches 0/0
50% Functions 1/2
50% Lines 3/6
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 26 27 28 29          1x     1x                 1x                      
import { getDevices, deleteDevice } from 'node-simctl';
import log from '../logger';
import _ from 'lodash';
 
 
let extensions = {};
 
async function getAllUdids () {
  let devices = await getDevices();
 
  return _.chain(devices)
    .values()
    .flatten()
    .map('udid')
    .value();
}
 
extensions.isolateSim = async function () {
  log.debug("Isolating the requested simulator by deleting all others");
  let udids = await getAllUdids();
 
  for (let udid of _.without(udids, this.udid)) {
    await deleteDevice(udid);
  }
};
 
 
export { extensions, getAllUdids };