UNPKG

sfdx-experiences-plugin

Version:
26 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const fs_extra_1 = require("fs-extra"); /** * Copies the given source route file to the given target route file. Transforms app page IDs if given. * * @param {string} sourceFile Path to the source route file. * @param {string} targetFile Path to the target route file. * @param {Map<string, string>} [appPageIdMap] Optional mapping of app page IDs. */ function copyRouteFile(sourceFile, targetFile, appPageIdMap) { if (!fs_1.existsSync(sourceFile)) { throw new Error(`Source route file does not exist: ${sourceFile}`); } const routeContent = fs_extra_1.readJsonSync(sourceFile); if (appPageIdMap) { if (!appPageIdMap.has(routeContent.appPageId)) { throw new Error(`Unable to map appPageId of source route file: ${sourceFile}`); } routeContent.appPageId = appPageIdMap.get(routeContent.appPageId); } fs_extra_1.writeJsonSync(targetFile, routeContent, { spaces: 2 }); } exports.default = copyRouteFile; //# sourceMappingURL=copy-route-file.js.map