X Tutup
Skip to content
Merged
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
7 changes: 1 addition & 6 deletions lib/device-controller.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="node" />
import { Platform, DeviceType, Status } from "./enums";
import { IDevice } from "./device";
export declare class DeviceController {
Expand All @@ -21,11 +20,7 @@ export declare class DeviceController {
static getApplicationId(device: IDevice, appFullPath: any): string;
static startRecordingVideo(device: IDevice, dir: any, fileName: any): {
pathToVideo: string;
devicePath: string;
videoRecordingProcess: import("child_process").ChildProcess;
} | {
pathToVideo: string;
videoRecoringProcess: any;
videoRecordingProcess: any;
};
static kill(device: IDevice): Promise<void>;
static killAll(type: DeviceType): void;
Expand Down
2 changes: 1 addition & 1 deletion lib/ios-controller.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export declare class IOSController {
static recordVideo(device: IDevice, dir: any, fileName: any, callback: () => Promise<any>): Promise<any>;
static startRecordingVideo(device: IDevice, dir: any, fileName: any): {
pathToVideo: string;
videoRecoringProcess: any;
videoRecordingProcess: any;
};
private static checkIfSimulatorIsBooted;
static getBundleId(deviceType: DeviceType, fullAppName: any): string;
Expand Down
28 changes: 14 additions & 14 deletions lib/ios-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export class IOSController {
Object.getOwnPropertyNames(devicesObj["devices"])
.forEach(level => {
deviceObjDevice[level]
.filter(d => d.availability === "(available)")
.filter(d => d["availability"] === "(available)" || !!d["isAvailable"])
.forEach(deviceObj => {
const status: Status = <Status>deviceObj.state.toLowerCase();
const apiLevel = /\d{1,3}(\.|\-)+.+|\d+/.exec(level)[0].replace("-", ".");
Expand Down Expand Up @@ -591,16 +591,16 @@ export class IOSController {
}

public static async recordVideo(device: IDevice, dir, fileName, callback: () => Promise<any>): Promise<any> {
const { pathToVideo, videoRecoringProcess } = IOSController.startRecordingVideo(device, dir, fileName);
const { pathToVideo, videoRecordingProcess } = IOSController.startRecordingVideo(device, dir, fileName);

return new Promise(async (res, reject) => {
callback().then((result) => {
videoRecoringProcess.kill("SIGINT");
videoRecordingProcess.kill("SIGINT");
console.log(result);
res(pathToVideo);
}).catch((error) => {
if (videoRecoringProcess) {
videoRecoringProcess.kill("SIGINT");
if (videoRecordingProcess) {
videoRecordingProcess.kill("SIGINT");
}
console.log('', error);
reject(error);
Expand All @@ -613,7 +613,7 @@ export class IOSController {
if (existsSync(pathToVideo)) {
unlinkSync(pathToVideo);
}
let videoRecoringProcess;
let videoRecordingProcess;
if (device.type === DeviceType.DEVICE) {
const p = resolve(__dirname, "../", "bin", "xrecord");
console.log(`${p} --quicktime --id=${device.token} --out=${pathToVideo} --force`);
Expand All @@ -625,7 +625,7 @@ export class IOSController {
});
}

videoRecoringProcess = startRecording();
videoRecordingProcess = startRecording();
wait(3000);

const checkHasStartedRecording = (timeout, pathToVideo) => {
Expand All @@ -643,7 +643,7 @@ export class IOSController {
execSync("killall 'QuickTime Player'");
} catch (error) { }
try {
videoRecoringProcess.kill("SIGTERM");
videoRecordingProcess.kill("SIGTERM");
} catch (error) { }

retryCount--;
Expand All @@ -655,7 +655,7 @@ export class IOSController {
stdio: 'inherit'
});

videoRecoringProcess = startRecording();
videoRecordingProcess = startRecording();
awaitOnRecordingStart = true;
}

Expand All @@ -664,22 +664,22 @@ export class IOSController {
if (!existsSync(pathToVideo)) {
console.error(`Couldn't start recording process!`);
console.error(`Recording couldn't be started! Check device connection and quick time player`);
videoRecoringProcess = null;
videoRecordingProcess = null;
pathToVideo = null;
}
} else {
console.log(`${IOSController.XCRUN} simctl io ${device.token} recordVideo ${pathToVideo}`);
videoRecoringProcess = spawn(`xcrun`, ['simctl ', 'io', device.token, 'recordVideo', `'${pathToVideo}'`], {
videoRecordingProcess = spawn(`xcrun`, ['simctl ', 'io', device.token, 'recordVideo', `'${pathToVideo}'`], {
cwd: process.cwd(),
shell: true,
stdio: 'inherit'
});
}
if (videoRecoringProcess) {
IOSController.runningProcesses.push(videoRecoringProcess.pid);
if (videoRecordingProcess) {
IOSController.runningProcesses.push(videoRecordingProcess.pid);
}

return { pathToVideo: pathToVideo, videoRecoringProcess: videoRecoringProcess };
return { pathToVideo: pathToVideo, videoRecordingProcess: videoRecordingProcess };
}

// Should find a better way
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobile-devices-controller",
"version": "5.0.4",
"version": "5.1.0",
"main": "index.js",
"description": "Manage devices, emulators and simulators.",
"keywords": [
Expand Down
X Tutup