Add UI reporter class (#389)
* Add truffle.library.js (5.0.31) as fail-safe for require('truffle') * Report truffle and ganache-core versionspull/390/head
parent
cc3e18a34a
commit
0b54cf39eb
File diff suppressed because one or more lines are too long
@ -0,0 +1,53 @@ |
|||||||
|
const c = require('chalk'); |
||||||
|
const emoji = require('node-emoji'); |
||||||
|
|
||||||
|
/** |
||||||
|
* Coverage tool output handler. This is where any logging solidity-coverage does on its |
||||||
|
* own behalf is managed. NB, most output is generated by the host dev stack (e.g. truffle, |
||||||
|
* buidler or by the coverage generator (e.g. Istanbul). |
||||||
|
* ) |
||||||
|
*/ |
||||||
|
class UI { |
||||||
|
constructor(log){ |
||||||
|
this.log = log || console.log; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Writes a formatted message to console |
||||||
|
* @param {String} kind message selector |
||||||
|
* @param {String[]} args info to inject into template |
||||||
|
*/ |
||||||
|
report(kind, args=[]){ |
||||||
|
const ct = c.bold.green('>'); |
||||||
|
const ds = c.bold.yellow('>'); |
||||||
|
|
||||||
|
const kinds = { |
||||||
|
|
||||||
|
'truffle-version': `${ct} ${c.bold('truffle')}: v${args[0]}`, |
||||||
|
'ganache-version': `${ct} ${c.bold('ganache-core')}: ${args[0]}`, |
||||||
|
|
||||||
|
'instr-start': `\n${c.bold('Instrumenting for coverage...')}` + |
||||||
|
`\n${c.bold('=============================')}\n`, |
||||||
|
|
||||||
|
'instr-skip': `\n${c.bold('Coverage skipped for:')}` + |
||||||
|
`\n${c.bold('=====================')}\n`, |
||||||
|
|
||||||
|
'instr-item': `${ct} ${args[0]}`, |
||||||
|
'instr-skipped': `${ds} ${c.grey(args[0])}` |
||||||
|
} |
||||||
|
|
||||||
|
this.log(emoji.emojify(kinds[kind])); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns a formatted message. Useful for error message. |
||||||
|
* @param {String} kind message selector |
||||||
|
* @param {String[]} args info to inject into template |
||||||
|
* @return {String} message |
||||||
|
*/ |
||||||
|
generate(kind, args){ |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = UI; |
Loading…
Reference in new issue