UNPKG

@egodigital/nef

Version:

Managed Extensibility Framework like library written for Node.js

62 lines 2.17 kB
"use strict"; /** * This file is part of the @egodigital/nef distribution. * Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/) * * @egodigital/nef is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, version 3. * * @egodigital/nef is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.FileCatalog = void 0; const _ = require("lodash"); const path = require("path"); const CatalogBase_1 = require("./CatalogBase"); const util_1 = require("../util"); /** * A catalog based on a JavaScript module in a file. */ class FileCatalog extends CatalogBase_1.CatalogBase { /** * Initializes a new instance of that class. * * @param {string} file The path to the file. * @param {FileCatalogOptions} [options] Custom options. */ constructor(file, options) { super(); this.file = file; this.options = options; this.file = util_1.toStringSafe(file); if (_.isNil(this.options)) { this.options = {}; } let cwd = util_1.toStringSafe(this.options.cwd); if ('' === cwd.trim()) { cwd = process.cwd(); } else { if (!path.isAbsolute(cwd)) { cwd = path.join(process.cwd(), cwd); } } if (!path.isAbsolute(this.file)) { this.file = path.join(cwd, this.file); } this.file = path.resolve(this.file); } /** @inheritdoc */ getClassesSync() { return util_1.getClassesFromObject(util_1.loadModule(this.file, true)); } } exports.FileCatalog = FileCatalog; //# sourceMappingURL=FileCatalog.js.map