"use strict";
var path = require("path");
var XcodeSelectService = (function () {
    function XcodeSelectService($childProcess, $errors, $hostInfo) {
        this.$childProcess = $childProcess;
        this.$errors = $errors;
        this.$hostInfo = $hostInfo;
    }
    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()();
    };
    return XcodeSelectService;
})();
exports.XcodeSelectService = XcodeSelectService;
$injector.register("xcodeSelectService", XcodeSelectService);
