all files / lib/utils/ colorize.js

100% Statements 11/11
50% Branches 2/4
100% Functions 1/1
100% Lines 11/11
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 26 27 28 29 30 31 32                                         
/**
 * gulp-scss-lint-stylish | lib/utils/colorize.js
 */
'use strict';
 
// // // // // // // // // // // // // // // // // // // // // // // // // // //
 
module.exports = function colorize($str, $color1, $color2)
{
    var $matches = $str.split(/(`[^`]+`)/g);
    var $match;
 
    Eif ($matches)
    {
        $str = [];
 
        for (var $i = 0, $iL = $matches.length; $i < $iL; $i++)
        {
            $match = $matches[$i];
            $match = (($match.substr(0, 1) === '`') ?
                      $color2($match) :
                      $color1($match));
 
            $str.push($match);
        }
 
        $str = $str.join('');
    }
 
    return $str;
};