UNPKG

@contract-case/case-core

Version:

Core functionality for the ContractCase contract testing suite

35 lines 1.62 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.consumerSlug = exports.providerSlug = void 0; const filenamify_1 = __importDefault(require("filenamify")); const slug_1 = __importDefault(require("slug")); const entities_1 = require("../../entities"); const SLUG_CONFIG = { ...slug_1.default.defaults.modes.pretty, // This exists so that we preserve `_` in strings we want to slug charmap: { ...slug_1.default.defaults.modes.pretty.charmap, _: '_' }, }; const customSlug = (toSlug) => (0, slug_1.default)(toSlug, SLUG_CONFIG); const escapeFileName = (pathString) => (0, filenamify_1.default)(pathString, { maxLength: entities_1.MAX_FILENAME_LENGTH }); /** * Normalises a provider name to a slug safe for the file system. * * This is in the core package, because we don't want this behaviour * to change based on the filesystem, and because the verification * result types need it. */ const providerSlug = (contract) => escapeFileName(customSlug(contract.description.providerName)); exports.providerSlug = providerSlug; /** * Normalises a consumer name to a slug safe for the file system * * This is in the core package, because we don't want this behaviour * to change based on the filesystem, and because the verification * result types need it. */ const consumerSlug = (contract) => escapeFileName(customSlug(contract.description.consumerName)); exports.consumerSlug = consumerSlug; //# sourceMappingURL=slugs.js.map