UNPKG

@typed/content-hash

Version:

Content hash a directory of HTML/JS/CSS files and other static assets

20 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeRegistry = void 0; const function_1 = require("fp-ts/function"); const Option_1 = require("fp-ts/Option"); const path_1 = require("path"); function normalizeRegistry(directory, registry) { return Object.fromEntries(Array.from(registry).map(([path, doc]) => [path_1.posix.relative(directory, path), normalizeDoc(directory, doc)])); } exports.normalizeRegistry = normalizeRegistry; function normalizeDoc(directory, document) { return { ...document, dependencies: document.dependencies.map((d) => ({ ...d, filePath: path_1.posix.relative(directory, d.filePath) })), filePath: path_1.posix.relative(directory, document.filePath), sourceMap: (0, function_1.pipe)(document.sourceMap, (0, Option_1.map)((p) => path_1.posix.relative(directory, p))), contentHash: (0, function_1.pipe)(document.contentHash, (0, Option_1.map)((hash) => (hash.type === 'hashFor' ? { ...hash, filePath: path_1.posix.relative(directory, hash.filePath) } : hash))), }; } //# sourceMappingURL=normalizeRegistry.js.map