UNPKG

webserv

Version:

a quick, flexible, fully typed development server

52 lines 2.31 kB
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()); }); }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "path", "../../core/util/file/exists"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const exists_1 = require("../../core/util/file/exists"); /** * Loads the configuration file from the provided path */ function loadConfigFile(path) { const configPath = path_1.resolve(path); const config = require(configPath); return { config, configPath }; } /** * Loads the configuration file from the default location relative to the cwd */ function loadDefaultConfig() { return __awaiter(this, void 0, void 0, function* () { const configPath = path_1.resolve('./webserv.json'); if (yield exists_1.fileExists(configPath)) { const config = require(configPath); return { config, configPath }; } return undefined; }); } /** * @returns a config at the provided path, the default config, or undefined if none exist */ function loadConfig(path) { return path ? loadConfigFile(path) : loadDefaultConfig(); } exports.loadConfig = loadConfig; }); //# sourceMappingURL=config.js.map