Skip to content

Commit a238230

Browse files
pmarchinitargos
authored andcommitted
lib: refactor code to improve readability
PR-URL: #55995 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
1 parent a1b2660 commit a238230

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

lib/internal/util/colors.js

+21-10
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,27 @@ module.exports = {
2424
stream.getColorDepth() > 2 : true);
2525
},
2626
refresh() {
27-
const hasColors = module.exports.shouldColorize(process.stderr);
28-
module.exports.blue = hasColors ? '\u001b[34m' : '';
29-
module.exports.green = hasColors ? '\u001b[32m' : '';
30-
module.exports.white = hasColors ? '\u001b[39m' : '';
31-
module.exports.yellow = hasColors ? '\u001b[33m' : '';
32-
module.exports.red = hasColors ? '\u001b[31m' : '';
33-
module.exports.gray = hasColors ? '\u001b[90m' : '';
34-
module.exports.clear = hasColors ? '\u001bc' : '';
35-
module.exports.reset = hasColors ? '\u001b[0m' : '';
36-
module.exports.hasColors = hasColors;
27+
if (module.exports.shouldColorize(process.stderr)) {
28+
module.exports.blue = '\u001b[34m';
29+
module.exports.green = '\u001b[32m';
30+
module.exports.white = '\u001b[39m';
31+
module.exports.yellow = '\u001b[33m';
32+
module.exports.red = '\u001b[31m';
33+
module.exports.gray = '\u001b[90m';
34+
module.exports.clear = '\u001bc';
35+
module.exports.reset = '\u001b[0m';
36+
module.exports.hasColors = true;
37+
} else {
38+
module.exports.blue = '';
39+
module.exports.green = '';
40+
module.exports.white = '';
41+
module.exports.yellow = '';
42+
module.exports.red = '';
43+
module.exports.gray = '';
44+
module.exports.clear = '';
45+
module.exports.reset = '';
46+
module.exports.hasColors = false;
47+
}
3748
},
3849
};
3950

0 commit comments

Comments
 (0)