mobile-cli-lib
Version:
common lib used by different CLI
61 lines (60 loc) • 2.98 kB
JavaScript
"use strict";
var path = require("path");
var future = require("fibers/future");
var Wp8EmulatorServices = (function () {
function Wp8EmulatorServices($logger, $emulatorSettingsService, $errors, $childProcess, $devicePlatformsConstants, $hostInfo, $fs) {
this.$logger = $logger;
this.$emulatorSettingsService = $emulatorSettingsService;
this.$errors = $errors;
this.$childProcess = $childProcess;
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$hostInfo = $hostInfo;
this.$fs = $fs;
}
Object.defineProperty(Wp8EmulatorServices, "programFilesPath", {
get: function () {
return (process.arch === "x64") ? process.env["PROGRAMFILES(X86)"] : process.env.ProgramFiles;
},
enumerable: true,
configurable: true
});
Wp8EmulatorServices.prototype.getEmulatorId = function () {
return future.fromResult("");
};
Wp8EmulatorServices.prototype.checkDependencies = function () {
return future.fromResult();
};
Wp8EmulatorServices.prototype.checkAvailability = function () {
var _this = this;
return (function () {
if (!_this.$fs.exists(_this.getPathToEmulatorStarter()).wait()) {
_this.$errors.failWithoutHelp("You do not have Windows Phone 8 SDK installed. Please install it in order to continue.");
}
if (!_this.$hostInfo.isWindows) {
_this.$errors.fail("Windows Phone Emulator is available only on Windows 8 or later.");
}
var platform = _this.$devicePlatformsConstants.WP8;
if (!_this.$emulatorSettingsService.canStart(platform).wait()) {
_this.$errors.fail("The current project does not target Windows Phone 8 and cannot be run in the Windows Phone emulator.");
}
}).future()();
};
Wp8EmulatorServices.prototype.startEmulator = function () {
return future.fromResult("Not implemented.");
};
Wp8EmulatorServices.prototype.runApplicationOnEmulator = function (app, emulatorOptions) {
var _this = this;
return (function () {
_this.$logger.info("Starting Windows Phone Emulator");
var emulatorStarter = _this.getPathToEmulatorStarter();
_this.$childProcess.spawn(emulatorStarter, ["/installlaunch", app, "/targetdevice:xd"], { stdio: "ignore", detached: true }).unref();
}).future()();
};
Wp8EmulatorServices.prototype.getPathToEmulatorStarter = function () {
return path.join(Wp8EmulatorServices.programFilesPath, Wp8EmulatorServices.WP8_LAUNCHER_PATH, Wp8EmulatorServices.WP8_LAUNCHER);
};
Wp8EmulatorServices.WP8_LAUNCHER = "XapDeployCmd.exe";
Wp8EmulatorServices.WP8_LAUNCHER_PATH = "Microsoft SDKs\\Windows Phone\\v8.0\\Tools\\XAP Deployment";
return Wp8EmulatorServices;
}());
$injector.register("wp8EmulatorServices", Wp8EmulatorServices);