Skip to content

Commit

Permalink
Migrate from chalk to picocolors
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored and Daniel15 committed Jul 15, 2024
1 parent 6d2d827 commit 64bb672
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/preset-flow": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@babel/register": "^7.24.6",
"chalk": "^4.1.2",
"picocolors": "^1.0.1",
"flow-parser": "0.*",
"graceful-fs": "^4.2.4",
"micromatch": "^4.0.7",
Expand Down
30 changes: 15 additions & 15 deletions src/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'use strict';

const child_process = require('child_process');
const chalk = require('chalk');
const pc = require('picocolors');
const fs = require('graceful-fs');
const path = require('path');
const http = require('http');
Expand Down Expand Up @@ -47,21 +47,21 @@ const bufferedWrite = (function() {

const log = {
ok(msg, verbose) {
verbose >= 2 && bufferedWrite(chalk.white.bgGreen(' OKK ') + msg);
verbose >= 2 && bufferedWrite(pc.bgGreen(pc.white(' OKK ')) + msg);
},
nochange(msg, verbose) {
verbose >= 1 && bufferedWrite(chalk.white.bgYellow(' NOC ') + msg);
verbose >= 1 && bufferedWrite(pc.bgYellow(pc.white(' NOC ')) + msg);
},
skip(msg, verbose) {
verbose >= 1 && bufferedWrite(chalk.white.bgYellow(' SKIP ') + msg);
verbose >= 1 && bufferedWrite(pc.bgYellow(pc.white(' SKIP ')) + msg);
},
error(msg, verbose) {
verbose >= 0 && bufferedWrite(chalk.white.bgRed(' ERR ') + msg);
verbose >= 0 && bufferedWrite(pc.bgRed(pc.white(' ERR ')) + msg);
},
};

function report({file, msg}) {
bufferedWrite(lineBreak(`${chalk.white.bgBlue(' REP ')}${file} ${msg}`));
bufferedWrite(lineBreak(`${pc.bgBlue(pc.white(' REP '))}${file} ${msg}`));
}

function concatAll(arrays) {
Expand All @@ -77,17 +77,17 @@ function concatAll(arrays) {
function showFileStats(fileStats) {
process.stdout.write(
'Results: \n'+
chalk.red(fileStats.error + ' errors\n')+
chalk.yellow(fileStats.nochange + ' unmodified\n')+
chalk.yellow(fileStats.skip + ' skipped\n')+
chalk.green(fileStats.ok + ' ok\n')
pc.red(fileStats.error + ' errors\n')+
pc.yellow(fileStats.nochange + ' unmodified\n')+
pc.yellow(fileStats.skip + ' skipped\n')+
pc.green(fileStats.ok + ' ok\n')
);
}

function showStats(stats) {
const names = Object.keys(stats).sort();
if (names.length) {
process.stdout.write(chalk.blue('Stats: \n'));
process.stdout.write(pc.blue('Stats: \n'));
}
names.forEach(name => process.stdout.write(name + ': ' + stats[name] + '\n'));
}
Expand Down Expand Up @@ -177,7 +177,7 @@ function run(transformFile, paths, options) {
let gitIgnorePath = path.join(currDirectory, '.gitignore');
ignores.addFromFile(gitIgnorePath);
}

if (/^http/.test(transformFile)) {
usedRemoteScript = true;
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -208,7 +208,7 @@ function run(transformFile, paths, options) {
});
} else if (!fs.existsSync(transformFile)) {
process.stderr.write(
chalk.white.bgRed('ERROR') + ' Transform file ' + transformFile + ' does not exist \n'
pc.bgRed(pc.white('ERROR')) + ' Transform file ' + transformFile + ' does not exist \n'
);
return;
} else {
Expand Down Expand Up @@ -254,7 +254,7 @@ function run(transformFile, paths, options) {
}
if (options.dry) {
process.stdout.write(
chalk.green('Running in dry mode, no files will be written! \n')
pc.green('Running in dry mode, no files will be written! \n')
);
}
}
Expand Down Expand Up @@ -305,7 +305,7 @@ function run(transformFile, paths, options) {
process.stdout.write(
'Time elapsed: ' + timeElapsed + 'seconds \n'
);

if (options.failOnError && fileCounters.error > 0) {
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ chalk@^2.4.2:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

chalk@^4.0.0, chalk@^4.1.2:
chalk@^4.0.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
Expand Down

0 comments on commit 64bb672

Please sign in to comment.