Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function shutdownOtherSimulators (currentDevice) {
const allDevices = _.flatMap(_.values(await getDevices()));
const otherBootedDevices = allDevices.filter((device) => device.udid !== currentDevice.udid && device.state === 'Booted');
if (_.isEmpty(otherBootedDevices)) {
log.info('No other running simulators have been detected');
return;
}
log.info(`Detected ${otherBootedDevices.length} other running Simulator${otherBootedDevices.length === 1 ? '' : 's'}.` +
`Shutting ${otherBootedDevices.length === 1 ? 'it' : 'them'} down...`);
for (const {udid} of otherBootedDevices) {
// It is necessary to stop the corresponding xcodebuild process before killing
// the simulator, otherwise it will be automatically restarted
await resetTestProcesses(udid, true);
await shutdown(udid);
}
}
async function shutdownSimulator (device) {
// stop XCTest processes if running to avoid unexpected side effects
await resetTestProcesses(device.udid, true);
await device.shutdown();
}
async function killAllSimulators () {
if (process.env.CLOUD) {
return;
}
const allDevices = _.flatMap(_.values(await getDevices()));
const bootedDevices = allDevices.filter((device) => device.state === 'Booted');
for (const {udid} of bootedDevices) {
// It is necessary to stop the corresponding xcodebuild process before killing
// the simulator, otherwise it will be automatically restarted
await resetTestProcesses(udid, true);
await shutdown(udid);
}
await simKill();
}