All files / app/codeCharta/state/effects/updateFileSettings/utils markedPackages.merger.ts

90.9% Statements 10/11
50% Branches 2/4
100% Functions 1/1
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 262x     2x 7x       7x   7x 14x 13x 10x           10x       7x    
import { getUpdatedBlacklistItemPath } from "../../../../util/nodePathHelper"
import { CCFile, MarkedPackage } from "../../../../codeCharta.model"
 
export function getMergedMarkedPackages(inputFiles: CCFile[], withUpdatedPath: boolean) {
    Iif (inputFiles.length === 1) {
        return inputFiles[0].settings.fileSettings.markedPackages
    }
 
    const markedPackages: Map<string, MarkedPackage> = new Map()
 
    for (const inputFile of inputFiles) {
        if (inputFile.settings.fileSettings.markedPackages) {
            for (const oldMarkedPackages of inputFile.settings.fileSettings.markedPackages) {
                const markedPackage: MarkedPackage = {
                    path: withUpdatedPath
                        ? getUpdatedBlacklistItemPath(inputFile.fileMeta.fileName, oldMarkedPackages.path)
                        : oldMarkedPackages.path,
                    color: oldMarkedPackages.color
                }
                markedPackages.set(`${markedPackage.path}|${markedPackage.color}`, markedPackage)
            }
        }
    }
    return [...markedPackages.values()]
}