nativescript
Version:
Command-line interface for building NativeScript projects
59 lines • 2.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IOSSimulatorLogProvider = void 0;
const events_1 = require("events");
const _ = require("lodash");
const yok_1 = require("../../../yok");
class IOSSimulatorLogProvider extends events_1.EventEmitter {
constructor($iOSSimResolver, $logger, $devicePlatformsConstants, $deviceLogProvider) {
super();
this.$iOSSimResolver = $iOSSimResolver;
this.$logger = $logger;
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$deviceLogProvider = $deviceLogProvider;
this.simulatorsLoggingEnabled = {};
this.simulatorsLogProcess = {};
this.shouldDispose = true;
}
setShouldDispose(shouldDispose) {
this.shouldDispose = shouldDispose;
}
async startLogProcess(deviceId, options) {
if (!this.simulatorsLoggingEnabled[deviceId]) {
const deviceLogChildProcess = await this.$iOSSimResolver.iOSSim.getDeviceLogProcess(deviceId, options ? options.predicate : null);
const action = (data) => {
const message = data.toString();
this.$deviceLogProvider.logData(message, this.$devicePlatformsConstants.iOS, deviceId);
};
if (deviceLogChildProcess) {
deviceLogChildProcess.once("close", () => {
this.simulatorsLoggingEnabled[deviceId] = false;
});
deviceLogChildProcess.once("error", (err) => {
this.$logger.trace(`Error is thrown for device with identifier ${deviceId}. More info: ${err.message}.`);
this.simulatorsLoggingEnabled[deviceId] = false;
});
}
if (deviceLogChildProcess.stdout) {
deviceLogChildProcess.stdout.on("data", action.bind(this));
}
if (deviceLogChildProcess.stderr) {
deviceLogChildProcess.stderr.on("data", action.bind(this));
}
this.simulatorsLoggingEnabled[deviceId] = true;
this.simulatorsLogProcess[deviceId] = deviceLogChildProcess;
}
}
dispose(signal) {
if (this.shouldDispose) {
_.each(this.simulatorsLogProcess, (logProcess, deviceId) => {
if (logProcess) {
logProcess.kill(signal);
}
});
}
}
}
exports.IOSSimulatorLogProvider = IOSSimulatorLogProvider;
yok_1.injector.register("iOSSimulatorLogProvider", IOSSimulatorLogProvider);
//# sourceMappingURL=ios-simulator-log-provider.js.map