"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_extra_1 = require("fs-extra");
const workerpool_1 = require("workerpool");
const linkNodeModules_1 = require("../../utils/linkNodeModules");
const common_worker_1 = require("./common.worker");
const utils_1 = require("./utils");
workerpool_1.worker({
    validateLayout: common_worker_1.validateLayout,
    initTemplate,
    linkModules,
    updateSettings: common_worker_1.updateSettings,
    build: common_worker_1.build,
    archive: common_worker_1.archive,
});
function initTemplate({ baseDir, layoutPath, dest }) {
    return __awaiter(this, void 0, void 0, function* () {
        const layoutFiles = yield utils_1.getLayoutFiles(layoutPath);
        yield fs_extra_1.emptyDir(dest);
        yield utils_1.copyMasterTemplateFiles(baseDir, layoutPath, dest, layoutFiles);
        yield utils_1.copyLayoutFiles(layoutPath, dest);
    });
}
function linkModules({ baseDir, dest }) {
    return linkNodeModules_1.linkNodeModules(baseDir, dest);
}
//# sourceMappingURL=layout.worker.js.map