Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to picocolors #1606

Merged
merged 2 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/svgo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

const { red } = require('nanocolors');
const colors = require('picocolors');
const { program } = require('commander');
const makeProgram = require('../lib/svgo/coa');
makeProgram(program);
program.parseAsync(process.argv).catch(error => {
console.error(red(error.stack));
console.error(colors.red(error.stack));
process.exit(1);
});
10 changes: 5 additions & 5 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 { green, red } = require('nanocolors');
const colors = require('picocolors');
const { loadConfig, optimize } = require('../svgo-node.js');
const pluginsMap = require('../../plugins/plugins.js');
const PKG = require('../../package.json');
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = function makeProgram(program) {
'Only output error messages, not regular status messages'
)
.option('--show-plugins', 'Show available plugins and exit')
// used by nanocolors internally
// used by picocolors internally
.option('--no-color', 'Output plain text without color')
.action(action);
};
Expand Down Expand Up @@ -387,7 +387,7 @@ function processSVGData(config, info, data, output, input) {

const result = optimize(data, { ...config, ...info });
if (result.modernError) {
console.error(red(result.modernError.toString()));
console.error(colors.red(result.modernError.toString()));
process.exit(1);
}
if (config.datauri) {
Expand Down Expand Up @@ -457,7 +457,7 @@ function printProfitInfo(inBytes, outBytes) {
Math.round((inBytes / 1024) * 1000) / 1000 +
' KiB' +
(profitPercents < 0 ? ' + ' : ' - ') +
green(Math.abs(Math.round(profitPercents * 10) / 10) + '%') +
colors.green(Math.abs(Math.round(profitPercents * 10) / 10) + '%') +
' = ' +
Math.round((outBytes / 1024) * 1000) / 1000 +
' KiB'
Expand Down Expand Up @@ -509,7 +509,7 @@ function checkWriteFileError(input, output, data, error) {
function showAvailablePlugins() {
const list = Object.entries(pluginsMap)
.sort(([a], [b]) => a.localeCompare(b))
.map(([name, plugin]) => ` [ ${green(name)} ] ${plugin.description}`)
.map(([name, plugin]) => ` [ ${colors.green(name)} ] ${plugin.description}`)
.join('\n');
console.log('Currently available plugins:\n' + list);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"css-select": "^4.1.3",
"css-tree": "^1.1.3",
"csso": "^4.2.0",
"nanocolors": "^0.2.1",
"picocolors": "^1.0.0",
"stable": "^0.1.8"
},
"devDependencies": {
Expand All @@ -117,7 +117,7 @@
"@types/jest": "^27.0.1",
"del": "^6.0.0",
"eslint": "^7.32.0",
"jest": "^27.2.1",
"jest": "^27.2.5",
"mock-stdin": "^1.0.0",
"node-fetch": "^2.6.2",
"pixelmatch": "^5.2.1",
Expand Down
Loading