Skip to content

Commit

Permalink
chore: colorize the debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Oct 23, 2020
1 parent 58f3410 commit dad0709
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/dev-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,18 @@ function startElectron() {
}

function electronLog(data, color) {
const colorize = (line) => {
if (line.startsWith('[INFO]')) {
return chalk.green('[INFO]') + line.substring(6)
} else if (line.startsWith('[WARN]')) {
return chalk.yellow('[WARN]') + line.substring(6)
} if (line.startsWith('[ERROR]')) {
return chalk.red('[ERROR]') + line.substring(7)
}
return line
}
data = data.toString().split(/\r?\n/);
console.log(data.filter(s => s.trim() !== '').join('\n'));
console.log(data.filter(s => s.trim() !== '').map(colorize).join('\n'));
}

function init() {
Expand Down

0 comments on commit dad0709

Please sign in to comment.