UNPKG

ts-bakery

Version:

Baked dependency injection for Typescript.

43 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs"); const path = require("path"); const TsBakeryConfigLoader_1 = require("../Configuration/TsBakeryConfigLoader"); class Paths { static get SourceRoot() { return TsBakeryConfigLoader_1.default.getSourceRoot(Paths.config); } static get DependenciesConfig() { const configDirectory = TsBakeryConfigLoader_1.default.getConfigDirectory(); return path.join(configDirectory, 'ts-bakery-dependencies.json'); } static get config() { if (!Paths._config) { Paths._config = TsBakeryConfigLoader_1.default.load(); } return Paths._config; } static validate() { if (!fs.existsSync(Paths.DependenciesConfig)) { throw new Error(`Could not find ts-bakery-dependencies.json in '${Paths.DependenciesConfig}'`); } } static resolveProjectRoot() { if (process.env.PWD) { return process.env.PWD; } return path.resolve(__dirname, '../../../..'); } static resolveDependencyResolverDeclaration() { const dtsFilePath = path.resolve(__dirname, '../Injection/DependencyResolver.d.ts'); if (fs.existsSync(dtsFilePath)) { return dtsFilePath; } return path.resolve(__dirname, '../Injection/DependencyResolver.ts'); } } exports.default = Paths; Paths._config = null; Paths.ProjectRoot = Paths.resolveProjectRoot(); Paths.DependencyResolverDeclaration = Paths.resolveDependencyResolverDeclaration(); //# sourceMappingURL=Paths.js.map