siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
105 lines (84 loc) • 3.19 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js">/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
<span id='Siesta-Util-Role-CanStyleOutput'>/**
</span>@class Siesta.Util.Role.CanStyleOutput
@private
A role, providing output coloring functionality
*/
Role('Siesta.Util.Role.CanStyleOutput', {
has : {
<span id='Siesta-Util-Role-CanStyleOutput-cfg-disableColoring'> /**
</span> * @cfg {Boolean} disableColoring When set to `true` will disable the colors in the console output in automation launchers / NodeJS launcher
*/
disableColoring : false,
style : {
is : 'rwc',
lazy : 'this.buildStyle'
},
styles : {
init : {
'bold' : [1, 22],
'italic' : [3, 23],
'underline' : [4, 24],
'black ' : [30, 39],
'yellow' : [33, 39],
'cyan' : [36, 39],
'white' : [37, 39],
'green' : [32, 39],
'red' : [31, 39],
'grey' : [90, 39],
'blue' : [34, 39],
'magenta' : [35, 39],
'bgblack ' : [40, 49],
'bgyellow' : [43, 49],
'bgcyan' : [46, 49],
'bgwhite' : [47, 49],
'bggreen' : [42, 49],
'bgred' : [41, 49],
'bggrey' : [100, 49],
'bgblue' : [44, 49],
'bgmagenta' : [45, 49],
'inverse' : [7, 27]
}
}
},
methods : {
buildStyle : function () {
var me = this
var style = {}
Joose.O.each(this.styles, function (value, name) {
style[ name ] = function (text) { return me.styled(text, name) }
})
return style
},
styled : function (text, style) {
if (this.disableColoring) return text
var styles = this.styles
return '\x1B[' + styles[ style ][ 0 ] + 'm' + text + '\x1B[' + styles[ style ][ 1 ] + 'm'
}
}
})
</pre>
</body>
</html>