Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getCrashes () {
let crashLogsRoot = this.logDir;
if (this.udid) {
this.phoneName = this.phoneName || await utilities.getDeviceName(this.udid);
crashLogsRoot = path.resolve(crashLogsRoot, this.phoneName);
}
if (!await fs.exists(crashLogsRoot)) {
log.debug(`Crash reports root '${crashLogsRoot}' does not exist. Got nothing to gather.`);
return [];
}
const foundFiles = await fs.glob(`${crashLogsRoot}/**/*.crash`);
if (this.udid) {
return foundFiles;
}
// For Simulator only include files, that contain current UDID
return await B.filter(foundFiles, async (x) => {
try {
const content = await fs.readFile(x, 'utf8');
return content.toUpperCase().includes(this.sim.udid.toUpperCase());
} catch (err) {