UNPKG

mobile-cli-lib

Version:
48 lines (47 loc) 2.24 kB
"use strict"; var path = require("path"); var XcodeSelectService = (function () { function XcodeSelectService($childProcess, $errors, $hostInfo, $injector) { this.$childProcess = $childProcess; this.$errors = $errors; this.$hostInfo = $hostInfo; this.$injector = $injector; } XcodeSelectService.prototype.getDeveloperDirectoryPath = function () { var _this = this; return (function () { if (!_this.$hostInfo.isDarwin) { _this.$errors.failWithoutHelp("xcode-select is only available on Mac OS X."); } var childProcess = _this.$childProcess.spawnFromEvent("xcode-select", ["-print-path"], "close", {}, { throwError: false }).wait(), result = childProcess.stdout.trim(); if (!result) { _this.$errors.failWithoutHelp("Cannot find path to Xcode.app - make sure you've installed Xcode correctly."); } return result; }).future()(); }; XcodeSelectService.prototype.getContentsDirectoryPath = function () { var _this = this; return (function () { return path.join(_this.getDeveloperDirectoryPath().wait(), ".."); }).future()(); }; XcodeSelectService.prototype.getXcodeVersion = function () { var _this = this; return (function () { if (!_this._xcodeVerionCache) { var sysInfoBase = _this.$injector.resolve("sysInfoBase"); var xcodeVer = sysInfoBase.getXCodeVersion().wait(), xcodeVersionMatch = xcodeVer.match(/Xcode (.*)/), xcodeVersionGroup = xcodeVersionMatch && xcodeVersionMatch[1], xcodeVersionSplit = xcodeVersionGroup && xcodeVersionGroup.split("."); _this._xcodeVerionCache = { major: xcodeVersionSplit && xcodeVersionSplit[0], minor: xcodeVersionSplit && xcodeVersionSplit[1], patch: xcodeVersionSplit && xcodeVersionSplit[2] }; } return _this._xcodeVerionCache; }).future()(); }; return XcodeSelectService; }()); exports.XcodeSelectService = XcodeSelectService; $injector.register("xcodeSelectService", XcodeSelectService);