UNPKG

firebase-tools

Version:
28 lines (27 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLocalAppHostingConfiguration = void 0; const path_1 = require("path"); const config_1 = require("../../apphosting/config"); const yaml_1 = require("../../apphosting/yaml"); async function getLocalAppHostingConfiguration(backendDir) { const appHostingConfigPaths = (0, config_1.listAppHostingFilesInPath)(backendDir); const fileNameToPathMap = new Map(); for (const path of appHostingConfigPaths) { const fileName = (0, path_1.basename)(path); fileNameToPathMap.set(fileName, path); } const baseFilePath = fileNameToPathMap.get(config_1.APPHOSTING_BASE_YAML_FILE); const localFilePath = fileNameToPathMap.get(config_1.APPHOSTING_LOCAL_YAML_FILE); if (!baseFilePath && !localFilePath) { return yaml_1.AppHostingYamlConfig.empty(); } if (!baseFilePath || !localFilePath) { return await yaml_1.AppHostingYamlConfig.loadFromFile((baseFilePath || localFilePath)); } const localYamlConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(localFilePath); const baseConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(baseFilePath); baseConfig.merge(localYamlConfig); return baseConfig; } exports.getLocalAppHostingConfiguration = getLocalAppHostingConfiguration;