src/utils.js
function getSVGMap(gmeConfig, logger, callback) {
    var svgAssetDir = gmeConfig.visualization.svgDirs[0],
        //path.join(__dirname, 'client', 'assets', 'DecoratorSVG'),
        svgMap;

    if (!svgAssetDir) {
        return Q.resolve({});
    }

    function joinPath(paths) {
        return '/' + paths.join('/');
    }

    function walkExtraDir(svgDir) {
        return walkDir(svgDir)
            .then(function (extraSvgFiles) {
                extraSvgFiles.forEach(function (fname) {
                    var dirName = path.parse(svgDir).name,
                        relativeFilePath = path.relative(svgDir, fname),
                        p = joinPath(['assets', 'DecoratorSVG', dirName].concat(relativeFilePath.split(path.sep)));

                    if (svgMap.hasOwnProperty(p)) {
                        logger.warn('Colliding SVG paths [', p, '] between [', svgMap[p], '] and [',
                            fname, ']. Will proceed and use the latter...');
                    }

                    fname = path.isAbsolute(fname) ? fname : path.join(process.cwd(), fname);
                    svgMap[p] = fname;
                });
            });
    }

    if (SVGMapDeffered) {
        return SVGMapDeffered.promise.nodeify(callback);
    }

    SVGMapDeffered = Q.defer();
    svgMap = {};

    walkDir(svgAssetDir)
        .then(function (svgFiles) {
            var extraDirs = gmeConfig.visualization.svgDirs.slice(1);
            svgFiles.forEach(function (fname) {
                var p = joinPath(['assets', 'DecoratorSVG', path.basename(fname)]);
                svgMap[p] = fname;
            });

            return Q.all(extraDirs.map(function (svgDir) {
                return walkExtraDir(svgDir);
            }));
        })
        .then(function () {
            SVGMapDeffered.resolve(svgMap);
        })
        .catch(SVGMapDeffered.reject);

    return SVGMapDeffered.promise.nodeify(callback);
}
function getSVGMap(gmeConfig, logger, callback) {
    var svgAssetDir = gmeConfig.visualization.svgDirs[0],
        //path.join(__dirname, 'client', 'assets', 'DecoratorSVG'),
        svgMap;

    if (!svgAssetDir) {
        return Q.resolve({});
    }

    function joinPath(paths) {
        return '/' + paths.join('/');
    }

    function walkExtraDir(svgDir) {
        return walkDir(svgDir)
            .then(function (extraSvgFiles) {
                extraSvgFiles.forEach(function (fname) {
                    var dirName = path.parse(svgDir).name,
                        relativeFilePath = path.relative(svgDir, fname),
                        p = joinPath(['assets', 'DecoratorSVG', dirName].concat(relativeFilePath.split(path.sep)));

                    if (svgMap.hasOwnProperty(p)) {
                        logger.warn('Colliding SVG paths [', p, '] between [', svgMap[p], '] and [',
                            fname, ']. Will proceed and use the latter...');
                    }

                    fname = path.isAbsolute(fname) ? fname : path.join(process.cwd(), fname);
                    svgMap[p] = fname;
                });
            });
    }

    if (SVGMapDeffered) {
        return SVGMapDeffered.promise.nodeify(callback);
    }

    SVGMapDeffered = Q.defer();
    svgMap = {};

    walkDir(svgAssetDir)
        .then(function (svgFiles) {
            var extraDirs = gmeConfig.visualization.svgDirs.slice(1);
            svgFiles.forEach(function (fname) {
                var p = joinPath(['assets', 'DecoratorSVG', path.basename(fname)]);
                svgMap[p] = fname;
            });

            return Q.all(extraDirs.map(function (svgDir) {
                return walkExtraDir(svgDir);
            }));
        })
        .then(function () {
            SVGMapDeffered.resolve(svgMap);
        })
        .catch(SVGMapDeffered.reject);

    return SVGMapDeffered.promise.nodeify(callback);
}
function getSVGMap ( gmeConfig , logger , callback ) { var svgAssetDir = gmeConfig . visualization . svgDirs [ 0 ] , //path.join(__dirname, 'client', 'assets', 'DecoratorSVG'), svgMap ; if ( ! svgAssetDir ) { return Q . resolve ( { } ) ; } function joinPath ( paths ) { return '/' + paths . join ( '/' ) ; } function walkExtraDir ( svgDir ) { return walkDir ( svgDir ) . then ( function ( extraSvgFiles ) { extraSvgFiles . forEach ( function ( fname ) { var dirName = path . parse ( svgDir ) . name , relativeFilePath = path . relative ( svgDir , fname ) , p = joinPath ( [ 'assets' , 'DecoratorSVG' , dirName ] . concat ( relativeFilePath . split ( path . sep ) ) ) ; if ( svgMap . hasOwnProperty ( p ) ) { logger . warn ( 'Colliding SVG paths [' , p , '] between [' , svgMap [ p ] , '] and [' , fname , ']. Will proceed and use the latter...' ) ; } fname = path . isAbsolute ( fname ) ? fname : path . join ( process . cwd ( ) , fname ) ; svgMap [ p ] = fname ; } ) ; } ) ; } if ( SVGMapDeffered ) { return SVGMapDeffered . promise . nodeify ( callback ) ; } SVGMapDeffered = Q . defer ( ) ; svgMap = { } ; walkDir ( svgAssetDir ) . then ( function ( svgFiles ) { var extraDirs = gmeConfig . visualization . svgDirs . slice ( 1 ) ; svgFiles . forEach ( function ( fname ) { var p = joinPath ( [ 'assets' , 'DecoratorSVG' , path . basename ( fname ) ] ) ; svgMap [ p ] = fname ; } ) ; return Q . all ( extraDirs . map ( function ( svgDir ) { return walkExtraDir ( svgDir ) ; } ) ) ; } ) . then ( function ( ) { SVGMapDeffered . resolve ( svgMap ) ; } ) . catch ( SVGMapDeffered . reject ) ; return SVGMapDeffered . promise . nodeify ( callback ) ; }
Note, the svgs in the first directory in gmeConfig.visualization.svgDirs will be added without
the dirname prefix for the svg.

With the following file structure:

./icons/svg1.svg
./icons2/svg2.svg
./icons3/svg3.svg

and gmeConfig.visualization.svgDirs = ['./icons', './icons2', './icons3'];

then the svgMap will have keys as follows:
{
'svg1.svg' : '...',
'icons2/svg2.svg': '...',
'icons3/svg3.svg': '...'
}


@param gmeConfig
@param logger
@param callback
@returns {*}
Note the svgs in the first directory in gmeConfig . visualization . svgDirs will be added without the dirname prefix for the svg .