UNPKG

workspace-tools

Version:

A collection of utilities that are useful in a git-controlled monorepo managed by one of these tools:

29 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.catalogsToYaml = void 0; /** * Convert catalogs to the yaml format used by yarn v4 and pnpm. */ function catalogsToYaml(catalogs, options = {}) { const { named, default: defaultCatalog } = catalogs; const lines = []; const indent = typeof options.indent === "string" ? options.indent : " ".repeat(options.indent ?? 2); if (defaultCatalog) { lines.push("catalog:"); for (const [pkg, version] of Object.entries(defaultCatalog)) { lines.push(`${indent}${pkg}: ${version}`); } } if (named) { lines.push("catalogs:"); for (const [catalogName, catalogEntries] of Object.entries(named)) { lines.push(`${indent}${catalogName}:`); for (const [pkg, version] of Object.entries(catalogEntries)) { lines.push(`${indent}${indent}${pkg}: ${version}`); } } } return lines.join("\n"); } exports.catalogsToYaml = catalogsToYaml; //# sourceMappingURL=catalogsToYaml.js.map