Code coverage report for lib/common/host-info.js

Statements: 47.73% (21 / 44)      Branches: 0% (0 / 15)      Functions: 25% (3 / 12)      Lines: 47.73% (21 / 44)      Ignored: none     

All files » lib/common/ » host-info.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98    1 1 1 69   1   66         1             1             1             1             1             1                                           1                                 1 1 1 1 1 1   1 1  
///<reference path=".d.ts"/>
"use strict";
var Future = require("fibers/future");
var HostInfo = (function () {
    function HostInfo($errors) {
        this.$errors = $errors;
    }
    Object.defineProperty(HostInfo.prototype, "isWindows", {
        get: function () {
            return process.platform === HostInfo.WIN32_NAME;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HostInfo.prototype, "isWindows64", {
        get: function () {
            return this.isWindows && (process.arch === "x64" || process.env.hasOwnProperty(HostInfo.PROCESSOR_ARCHITEW6432));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HostInfo.prototype, "isWindows32", {
        get: function () {
            return this.isWindows && !this.isWindows64;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HostInfo.prototype, "isDarwin", {
        get: function () {
            return process.platform === HostInfo.DARWIN_OS_NAME;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HostInfo.prototype, "isLinux", {
        get: function () {
            return process.platform === HostInfo.LINUX_OS_NAME;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(HostInfo.prototype, "isLinux64", {
        get: function () {
            return this.isLinux && process.config.variables.host_arch === "x64";
        },
        enumerable: true,
        configurable: true
    });
    HostInfo.prototype.dotNetVersion = function () {
        if (this.isWindows) {
            var result = new Future();
            var Winreg = require("winreg");
            var regKey = new Winreg({
                hive: Winreg.HKLM,
                key: HostInfo.DOT_NET_REGISTRY_PATH
            });
            regKey.get("Version", function (err, value) {
                if (err) {
                    result.throw(err);
                }
                else {
                    result.return(value.value);
                }
            });
            return result;
        }
        else {
            return Future.fromResult(null);
        }
    };
    HostInfo.prototype.isDotNet40Installed = function (message) {
        var _this = this;
        return (function () {
            if (_this.isWindows) {
                try {
                    _this.dotNetVersion().wait();
                    return true;
                }
                catch (e) {
                    _this.$errors.failWithoutHelp(message || "An error occurred while reading the registry.");
                }
            }
            else {
                return false;
            }
        }).future()();
    };
    HostInfo.WIN32_NAME = "win32";
    HostInfo.PROCESSOR_ARCHITEW6432 = "PROCESSOR_ARCHITEW6432";
    HostInfo.DARWIN_OS_NAME = "darwin";
    HostInfo.LINUX_OS_NAME = "linux";
    HostInfo.DOT_NET_REGISTRY_PATH = "\\Software\\Microsoft\\NET Framework Setup\\NDP\\v4\\Client";
    return HostInfo;
})();
exports.HostInfo = HostInfo;
$injector.register("hostInfo", HostInfo);