//#region imports
import { BaseClientCompiler, } from 'incremental-compiler/lib';
import { crossPlatformPath, Helpers } from 'tnp-core/lib';
import { _ } from 'tnp-core/lib';
import { config } from 'tnp-core/lib';
//#endregion
export class BaseCompilerForProject extends BaseClientCompiler {
    project;
    //#region check folder compiler
    checkFolderCompiler(project, options, dontCheck = false) {
        //#region @backendFunc
        if (_.isUndefined(options)) {
            return options;
        }
        if (_.isUndefined(options.folderPath)) {
            options.folderPath = [];
        }
        const folders = _.isArray(options.folderPath)
            ? options.folderPath
            : [options.folderPath];
        options.folderPath = folders.map(f => {
            f = crossPlatformPath(f);
            if (!dontCheck) {
                if (f.startsWith(crossPlatformPath([project.location, config.folder.node_modules]))) {
                    Helpers.error(`[checkFolderCompiler] Please don't watch node_module folder for ${project.location}`, false, true);
                }
                if (!f.startsWith(project.location) ||
                    f.startsWith(`${project.location}/..`)) {
                    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
    }
}
//# sourceMappingURL=base-compiler-for-project.js.map