"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var logger_1 = require("../logger/logger");
var ionic_project_1 = require("../util/ionic-project");
function createDevAppService(config) {
    if (!config.devapp) {
        return;
    }
    ionic_project_1.getProjectJson()
        .then(function (project) { return project.name; })
        .catch(function () { return 'ionic-app-scripts'; })
        .then(function (projectName) {
        try {
            var name_1 = startDevApp(projectName, config.httpPort);
            logger_1.Logger.info("publishing devapp service (" + name_1 + ")");
        }
        catch (e) {
            logger_1.Logger.warn('mDNS failed when trying to publish service');
            logger_1.Logger.warn(e);
        }
    });
}
exports.createDevAppService = createDevAppService;
function startDevApp(name, port) {
    var Publisher = require('@ionic/discover').Publisher;
    var service = new Publisher(name, port);
    service.start();
    return name;
}
