UNPKG

nativescript-unit-test-runner

Version:
37 lines (36 loc) 1.34 kB
Object.defineProperty(exports, "__esModule", { value: true }); var KarmaHostResolver = (function () { function KarmaHostResolver(http) { this.http = http; } KarmaHostResolver.prototype.resolveKarmaHost = function (ips, port) { var _this = this; var result = new Promise(function (resolve) { var foundKarma = false; var resolvers = ips.map(function (ip) { var karmaClientUrl = "http://" + ip + ":" + port + "/context.json"; console.log('NSUTR: fetching ' + karmaClientUrl); return _this.http.getString({ url: karmaClientUrl, method: 'GET', timeout: 3000, }).then(function () { console.log('NSUTR: found karma at ' + ip); if (!foundKarma) { foundKarma = true; resolve(ip); } }, function () { return undefined; }); }); Promise.all(resolvers) .then(function () { if (!foundKarma) { resolve(null); } }); }); return result; }; return KarmaHostResolver; }()); exports.KarmaHostResolver = KarmaHostResolver;