Improve message.js
Added: - Types "notice" and "warning". - Support for all but the "waiting" message type to stop a timer. Changed: - Improved colors of message types. - Improved handling of PostCSS errors in styles.js.
This commit is contained in:
@@ -48,10 +48,13 @@ export async function compileStyles() {
|
|||||||
sourcesContent: true
|
sourcesContent: true
|
||||||
}
|
}
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
result.warnings().forEach((warn) => {
|
const warnings = result.warnings();
|
||||||
message(`Error prefixing ${name}.css`, 'error');
|
if (warnings.length) {
|
||||||
message(warn.toString());
|
message(`Error processing ${name}.css`, 'warning');
|
||||||
});
|
warnings.forEach((warn) => {
|
||||||
|
message(warn.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
saveStylesheet(result, outfile, name, timeLabel);
|
saveStylesheet(result, outfile, name, timeLabel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,24 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @file Provides a decorator for console messages.
|
||||||
|
*/
|
||||||
|
|
||||||
import kleur from 'kleur';
|
import kleur from 'kleur';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs a message to the console.
|
||||||
|
*
|
||||||
|
* @param {string} text - The message to output.
|
||||||
|
* @param {string} [type] - The type of message.
|
||||||
|
* @param {string} [timerID] - The console time label to output.
|
||||||
|
*/
|
||||||
export default function message(text, type, timerID) {
|
export default function message(text, type, timerID) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'success':
|
case 'success':
|
||||||
console.log(kleur.bgGreen().black(`✅ ${text}`));
|
console.log('✅ ', kleur.bgGreen().black(text));
|
||||||
|
break;
|
||||||
|
|
||||||
if (timerID !== undefined) {
|
case 'notice':
|
||||||
console.timeEnd(timerID);
|
console.log('ℹ️ ', kleur.bgBlue().black(text));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'error':
|
case 'error':
|
||||||
console.log(kleur.red().underline(`❌ ${text}`));
|
console.log('❌ ', kleur.bgRed().black(text));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'warning':
|
||||||
|
console.log('⚠️ ', kleur.bgYellow().black(text));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'waiting':
|
case 'waiting':
|
||||||
console.log(kleur.blue().italic(`⏱ ${text}`));
|
console.log('⏱ ', kleur.blue().italic(text));
|
||||||
|
|
||||||
if (timerID !== undefined) {
|
if (timerID != null) {
|
||||||
console.timeLog(timerID);
|
console.timeLog(timerID);
|
||||||
|
timerID = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -27,5 +43,9 @@ export default function message(text, type, timerID) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timerID != null) {
|
||||||
|
console.timeEnd(timerID);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user