function mergePathMaps()

in src/FileUpdater.js [310:341]


function mergePathMaps (sourceMaps, targetMap, targetDir) {
    // Merge multiple source maps together, along with target path info.
    // Entries in later source maps override those in earlier source maps.
    const sourceMap = Object.assign({}, ...sourceMaps);

    const allKeys = [].concat(Object.keys(sourceMap), Object.keys(targetMap));
    const pathMap = allKeys.reduce((acc, subPath) => (
        Object.assign(acc, {
            [subPath]: {
                targetPath: path.join(targetDir, subPath),
                targetStats: null,
                sourcePath: null,
                sourceStats: null
            }
        })
    ), {});

    Object.entries(sourceMap).forEach(([subPath, { subDir, stats }]) => {
        Object.assign(
            pathMap[subPath],
            { sourcePath: path.join(subDir, subPath), sourceStats: stats }
        );
    });

    // Fill in target stats for targets that exist, and create entries
    // for targets that don't have any corresponding sources.
    Object.entries(targetMap).forEach(([subPath, { stats }]) => {
        Object.assign(pathMap[subPath], { targetStats: stats });
    });

    return pathMap;
}