Skip to content

Commit

Permalink
♻️ Create log() to handle console.log() with chalk
Browse files Browse the repository at this point in the history
  • Loading branch information
kghugo committed Aug 4, 2020
1 parent 605c8dd commit 8444cd4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions utilities/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ const isIncluded = (decl, inclusionRules) => {
return inclusionRules.some(unit => RegExp(unit).test(decl));
}

const log = (msgType) => {
const log = (msg, msgType) => {
switch (msgType) {
case 'success':

console.log(chalk.green(msg))
break;

case 'error':

console.log(chalk.red(msg))
break;
default:

Expand All @@ -40,12 +40,13 @@ const shouldBeTransformed = (decl, options) => {

for(const [index, value] of validationValues.entries() ){
if(! isIncluded(value, inclusionRules[index]) || isIncluded(value, exclusionRules[index]) ){
console.log(chalk.red(`${decl.parent.selector}{ ${decl.prop}: ${decl.value} } has been excluded`));
log(`${decl.parent.selector}{ ${decl.prop}: ${decl.value} } has been excluded`, 'error')
return false
}
}

console.log(chalk.green(`${decl.parent.selector}{ ${decl.prop}: ${decl.value} } has been wrapped with rfs()`));
log(`${decl.parent.selector}{ ${decl.prop}: ${decl.value} } has been wrapped with rfs()`, 'success')

return true
}

Expand Down

0 comments on commit 8444cd4

Please sign in to comment.