UNPKG

testplane

Version:

Tests framework based on mocha and wdio

39 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeHashes = void 0; const utils_1 = require("../utils"); const json_utils_1 = require("../json-utils"); const mergeHashes = async (destPath, selectivitySrcAbsolutePaths, preferredCompression) => { const selectivityHashesDestPath = (0, utils_1.getSelectivityHashesPath)(destPath); const sourceHashes = await Promise.all(selectivitySrcAbsolutePaths.map(sourcePath => { const selectivityHashesPath = (0, utils_1.getSelectivityHashesPath)(sourcePath); return (0, utils_1.readHashFileContents)(selectivityHashesPath, preferredCompression); })); const result = { files: {}, modules: {}, patterns: {}, }; const mergeFor = (source, hashType) => { const destination = result[hashType]; for (const key in source[hashType]) { if (!destination[key]) { destination[key] = source[hashType][key]; } else if (destination[key] !== source[hashType][key]) { throw new Error([ `Hashes for "${hashType}" "${key}" are not equal in different chunks`, "This could happen if selectivity dumps were generated on different file states", ].join("\n")); } } }; for (const sourceHash of sourceHashes) { mergeFor(sourceHash, "files"); mergeFor(sourceHash, "modules"); mergeFor(sourceHash, "patterns"); } await (0, json_utils_1.writeJsonWithCompression)(selectivityHashesDestPath, result, preferredCompression); }; exports.mergeHashes = mergeHashes; //# sourceMappingURL=merge-hashes.js.map