All files / src/utils shrink-paths.js

100% Statements 13/13
100% Branches 2/2
100% Functions 3/3
100% Lines 13/13
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    1x 1x   1x 4x   4x 8x 11x 11x 4x   7x       4x   4x     1x  
'use strict';
 
const Path = require('path');
const isObject = require('lodash/isObject');
 
const shrinkPaths = (basePath, pathsHash) => {
    const paths = [];
 
    const shrink = (path, hash) => {
        Object.keys(hash).forEach(key => {
            const newPath = Path.join(path, key);
            if (isObject(hash[key])) {
                return shrink(newPath, hash[key]);
            }
            paths.push(newPath);
        });
    };
 
    shrink(basePath, pathsHash);
 
    return paths;
};
 
module.exports = shrinkPaths;