UNPKG

pr-view

Version:

Preview deployments for your pull requests

60 lines 2.19 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs = __importStar(require("fs")); class PrViewConfig { constructor(appName, memorySize, framework, domain, component) { this.appName = appName; this.memorySize = memorySize; this.framework = framework; this.domain = domain; this.component = component; } static readFromFile() { let data; try { data = fs.readFileSync("pr-view.json"); } catch (err) { if (err.code === "ENOENT") { console.error("Config file pr-view.json is not found. Please run pr-view configure."); process.exit(1); } else { console.error("Error reading file. Please re-create this file."); process.exit(1); } } const config = JSON.parse(data.toString()); const appName = config["appName"]; const memorySize = config["memorySize"]; const framework = config["framework"]; const domain = config["domain"]; const component = config["component"]; let error = false; if (!appName) { console.error("Config attribute appName was not set. Please check your pr-view.json file."); error = true; } if (!memorySize) { console.error("Config attribute memorySize was not set. Please check your pr-view.json file."); error = true; } if (!framework) { console.error("Config attribute framework was not set. Please check your pr-view.json file."); error = true; } if (error) { process.exit(1); } return new PrViewConfig(appName, memorySize, framework, domain, component); } } exports.default = PrViewConfig; //# sourceMappingURL=config.js.map