Skip to content

Commit

Permalink
lib: refactor code to improve readability
Browse files Browse the repository at this point in the history
PR-URL: #55995
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: LiviaMedeiros <[email protected]>
  • Loading branch information
pmarchini authored Nov 27, 2024
1 parent e64f949 commit 24a8662
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions lib/internal/util/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@ module.exports = {
stream.getColorDepth() > 2 : true);
},
refresh() {
const hasColors = module.exports.shouldColorize(process.stderr);
module.exports.blue = hasColors ? '\u001b[34m' : '';
module.exports.green = hasColors ? '\u001b[32m' : '';
module.exports.white = hasColors ? '\u001b[39m' : '';
module.exports.yellow = hasColors ? '\u001b[33m' : '';
module.exports.red = hasColors ? '\u001b[31m' : '';
module.exports.gray = hasColors ? '\u001b[90m' : '';
module.exports.clear = hasColors ? '\u001bc' : '';
module.exports.reset = hasColors ? '\u001b[0m' : '';
module.exports.hasColors = hasColors;
if (module.exports.shouldColorize(process.stderr)) {
module.exports.blue = '\u001b[34m';
module.exports.green = '\u001b[32m';
module.exports.white = '\u001b[39m';
module.exports.yellow = '\u001b[33m';
module.exports.red = '\u001b[31m';
module.exports.gray = '\u001b[90m';
module.exports.clear = '\u001bc';
module.exports.reset = '\u001b[0m';
module.exports.hasColors = true;
} else {
module.exports.blue = '';
module.exports.green = '';
module.exports.white = '';
module.exports.yellow = '';
module.exports.red = '';
module.exports.gray = '';
module.exports.clear = '';
module.exports.reset = '';
module.exports.hasColors = false;
}
},
};

Expand Down

0 comments on commit 24a8662

Please sign in to comment.