Skip to content

Commit

Permalink
Replace colors dependency with chalk (svg#1061)
Browse files Browse the repository at this point in the history
use 'chalk' for colors in console
  • Loading branch information
xPaw authored and GreLI committed Feb 24, 2019
1 parent 7eeb5d0 commit eb0d66a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/svgo/coa.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* jshint quotmark: false */
'use strict';

require('colors');

var FS = require('fs'),
PATH = require('path'),
chalk = require('chalk'),
mkdirp = require('mkdirp'),
promisify = require('util.promisify'),
readdir = promisify(FS.readdir),
Expand Down Expand Up @@ -515,7 +514,7 @@ function printProfitInfo(inBytes, outBytes) {
console.log(
(Math.round((inBytes / 1024) * 1000) / 1000) + ' KiB' +
(profitPercents < 0 ? ' + ' : ' - ') +
String(Math.abs((Math.round(profitPercents * 10) / 10)) + '%').green + ' = ' +
chalk.green(Math.abs((Math.round(profitPercents * 10) / 10)) + '%') + ' = ' +
(Math.round((outBytes / 1024) * 1000) / 1000) + ' KiB'
);
}
Expand Down Expand Up @@ -562,7 +561,7 @@ function showAvailablePlugins() {
// Flatten an array of plugins grouped per type, sort and write output
var list = [].concat.apply([], new SVGO().config.plugins)
.sort((a, b) => a.name.localeCompare(b.name))
.map(plugin => ` [ ${plugin.name.green} ] ${plugin.description}`)
.map(plugin => ` [ ${chalk.green(plugin.name)} ] ${plugin.description}`)
.join('\n');
console.log(list);
}
Expand All @@ -573,7 +572,7 @@ function showAvailablePlugins() {
* @return {Promise} a promise for running tests
*/
function printErrorAndExit(error) {
console.error(error);
console.error(chalk.red(error));
process.exit(1);
return Promise.reject(error); // for tests
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"jshint": "npm run lint"
},
"dependencies": {
"chalk": "^2.4.1",
"coa": "~2.0.1",
"colors": "~1.1.2",
"css-select": "^2.0.0",
"css-select-base-adapter": "~0.1.0",
"css-tree": "1.0.0-alpha.28",
Expand Down

0 comments on commit eb0d66a

Please sign in to comment.