Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions src/utils/ADB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,29 @@ export class ADB {
}

connectedDevices(): AndroidDevice[] {
let devices: AndroidDevice[] = [];
const adbDevices: string = execSync('adb devices -l').toString();
const devices: AndroidDevice[] = [];

// 1) Intentamos ejecutar adb; si falla, devolvemos [] y no rompemos todo
let adbDevices: string;
try {
adbDevices = execSync('adb devices -l').toString();
} catch (err) {
// adb no está instalado o no está en el PATH
return devices;
}

// 2) Si adb funcionó, procesamos la salida normal
adbDevices.split('\n').forEach((line: string) => {
const id: any = this.extractDeviceIdFromLine(line);
const id: any = this.extractDeviceIdFromLine(line);
const model: any = this.extractDeviceModelFromLine(line);
if(!id || !model) { return; }

if (!id || !model) { return; }
devices.push(new AndroidDevice(id, model));
});

return devices;
}



deviceScreenSize(deviceId: string): number[] {
let adbScreenSize = execSync(`adb -s ${deviceId} shell wm size`).toString();
Expand Down
12 changes: 8 additions & 4 deletions src/utils/FileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ export class FileHelper {
}
}

createFileIfDoesNotExist(path: string) {
if (!fs.existsSync(path)) {
fs.openSync(path, 'w');
createFileIfDoesNotExist(filePath: string) {
// 1) Asegurarse de que la carpeta padre existe
const dir = path.dirname(filePath);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
}
// 2) Luego crear o abrir el fichero en modo append
fs.openSync(filePath, 'a');
}

contentOfFile(path: string): any {
const contents = fs.readFileSync(path, 'utf8');
Expand Down