Skip to content

Commit

Permalink
Replace chalk with colorette (#1511)
Browse files Browse the repository at this point in the history
Remove 5 deps from production install:
`ansi-styles`, `supports-color`, `color-convert`, `has-flag`, `color-name`.

Also reduce deps when using PostCSS and SVGO together, since PostCSS
uses colorette.

Tested with `yarn install svgo`.
  • Loading branch information
ludofischer authored Aug 4, 2021
1 parent cef184c commit c4ae19e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/svgo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const { red } = require('chalk');
const { red } = require('colorette');
const { program } = require('commander');
const makeProgram = require('../lib/svgo/coa');
makeProgram(program);
Expand Down
6 changes: 3 additions & 3 deletions lib/svgo/coa.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const FS = require('fs');
const PATH = require('path');
const chalk = require('chalk');
const { green } = require('colorette');
const { loadConfig, optimize } = require('../svgo-node.js');
const pluginsMap = require('../../plugins/plugins.js');
const PKG = require('../../package.json');
Expand Down Expand Up @@ -433,7 +433,7 @@ function printProfitInfo(inBytes, outBytes) {
Math.round((inBytes / 1024) * 1000) / 1000 +
' KiB' +
(profitPercents < 0 ? ' + ' : ' - ') +
chalk.green(Math.abs(Math.round(profitPercents * 10) / 10) + '%') +
green(Math.abs(Math.round(profitPercents * 10) / 10) + '%') +
' = ' +
Math.round((outBytes / 1024) * 1000) / 1000 +
' KiB'
Expand Down Expand Up @@ -485,7 +485,7 @@ function checkWriteFileError(input, output, data, error) {
function showAvailablePlugins() {
const list = Object.entries(pluginsMap)
.sort(([a], [b]) => a.localeCompare(b))
.map(([name, plugin]) => ` [ ${chalk.green(name)} ] ${plugin.description}`)
.map(([name, plugin]) => ` [ ${green(name)} ] ${plugin.description}`)
.join('\n');
console.log('Currently available plugins:\n' + list);
}
Expand Down
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
"dependencies": {
"@trysound/sax": "0.1.1",
"chalk": "^4.1.0",
"colorette": "^1.2.2",
"commander": "^7.1.0",
"css-select": "^4.1.3",
"css-tree": "^1.1.2",
Expand Down

0 comments on commit c4ae19e

Please sign in to comment.