UNPKG

apim-policy-utils

Version:

An XML file scripts maniputaling and debugging tool targeting to help working with Azure APIM Policy files in xml format.

51 lines 2.62 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.combineFromDirectory = void 0; const fs = __importStar(require("fs")); const path_1 = __importDefault(require("path")); const scriptCombiner_1 = require("./scriptCombiner"); const combineFromDirectory = async (directoryPath, destinationPath) => { const projectRoot = process.cwd(); let directoryPathResolved = path_1.default.resolve(projectRoot, directoryPath); let destinationPathResolved = destinationPath ? path_1.default.resolve(projectRoot, destinationPath) : undefined; directoryPathResolved = directoryPathResolved.endsWith('/') ? directoryPathResolved.slice(0, -1) : directoryPathResolved; destinationPathResolved = (destinationPathResolved === null || destinationPathResolved === void 0 ? void 0 : destinationPathResolved.endsWith('/')) ? destinationPathResolved.slice(0, -1) : destinationPathResolved; // Read subdir names to an array const subdirs = fs .readdirSync(directoryPathResolved, { withFileTypes: true }) .filter((dirent) => dirent.isDirectory()) .map((dirent) => dirent.name); // Iterate thru subdirs subdirs.forEach(async (subdir) => { const subdirPath = `${directoryPathResolved}/${subdir}`; await (0, scriptCombiner_1.combineScript)(subdirPath, destinationPathResolved); }); }; exports.combineFromDirectory = combineFromDirectory; //# sourceMappingURL=combiner.js.map