"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const reload_1 = __importDefault(require("reload"));
const chokidar_1 = __importDefault(require("chokidar"));
function liveReload(metadataPath) {
    let reloadReturned;
    let fileWatcher;
    return {
        extendApp: async ({ app }) => {
            reloadReturned = await reload_1.default(app);
            fileWatcher = chokidar_1.default.watch(metadataPath, {
                ignoreInitial: true
            });
            fileWatcher.on('change', () => {
                reloadReturned.reload();
            });
        },
        close: async () => {
            if (reloadReturned) {
                await reloadReturned.closeServer();
            }
            if (fileWatcher) {
                await fileWatcher.close();
            }
        }
    };
}
exports.liveReload = liveReload;
//# sourceMappingURL=liveReload.js.map