"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseCompilerForProject = void 0;
//#region imports
const lib_1 = require("incremental-compiler/lib");
const lib_2 = require("tnp-core/lib");
const lib_3 = require("tnp-core/lib");
const lib_4 = require("tnp-core/lib");
//#endregion
class BaseCompilerForProject extends lib_1.BaseClientCompiler {
    project;
    //#region check folder compiler
    checkFolderCompiler(project, options, dontCheck = false) {
        //#region @backendFunc
        if (lib_3._.isUndefined(options)) {
            return options;
        }
        if (lib_3._.isUndefined(options.folderPath)) {
            options.folderPath = [];
        }
        const folders = lib_3._.isArray(options.folderPath)
            ? options.folderPath
            : [options.folderPath];
        options.folderPath = folders.map(f => {
            f = (0, lib_2.crossPlatformPath)(f);
            if (!dontCheck) {
                if (f.startsWith((0, lib_2.crossPlatformPath)([project.location, lib_4.config.folder.node_modules]))) {
                    lib_2.Helpers.error(`[checkFolderCompiler] Please don't watch node_module folder for ${project.location}`, false, true);
                }
                if (!f.startsWith(project.location) ||
                    f.startsWith(`${project.location}/..`)) {
                    lib_2.Helpers.error(`[checkFolderCompiler] Please watch only folder inside project ${project.location}`, false, true);
                }
            }
            return f;
        });
        return options;
        //#endregion
    }
    //#endregion
    //#region constructor
    constructor(project, options, allowFolderOutSideProject = false) {
        super();
        this.project = project;
        //#region @backend
        options = this.checkFolderCompiler(project, options, allowFolderOutSideProject);
        if (options) {
            this.initOptions(options);
        }
        //#endregion
    }
}
exports.BaseCompilerForProject = BaseCompilerForProject;
//# sourceMappingURL=base-compiler-for-project.js.map