mirror of
https://github.com/locomotivemtl/locomotive-boilerplate.git
synced 2026-01-15 00:55:08 +08:00
Separated generic functions from build helpers. Changed: - Moved 'utils/*.js' to 'helpers/*.js' - From 'utils/config.js': - Moved function `merge` to 'utils/index.js'. - Moved function `isObjectLike` to 'utils/index.js'. - From 'utils/template.js': - Moved function `flatten` to 'utils/index.js'. - Moved function `escapeRegExp` to 'utils/index.js'. - From 'tasks/styles.js': - Moved function `createPostCSSProcessor` to 'helpers/postcss.js' as `createProcessor`. - Replaced function `Object.assign` with `merge` for task options parsing in all tasks.
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
/**
|
||
* @file Provides a decorator for console messages.
|
||
*/
|
||
|
||
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) {
|
||
switch (type) {
|
||
case 'success':
|
||
console.log('✅ ', kleur.bgGreen().black(text));
|
||
break;
|
||
|
||
case 'chore':
|
||
console.log('🧹 ', kleur.bgGreen().black(text));
|
||
break;
|
||
|
||
case 'notice':
|
||
console.log('ℹ️ ', kleur.bgBlue().black(text));
|
||
break;
|
||
|
||
case 'error':
|
||
console.log('❌ ', kleur.bgRed().black(text));
|
||
break;
|
||
|
||
case 'warning':
|
||
console.log('⚠️ ', kleur.bgYellow().black(text));
|
||
break;
|
||
|
||
case 'waiting':
|
||
console.log('⏱ ', kleur.blue().italic(text));
|
||
|
||
if (timerID != null) {
|
||
console.timeLog(timerID);
|
||
timerID = null;
|
||
}
|
||
break;
|
||
|
||
default:
|
||
console.log(text);
|
||
break;
|
||
}
|
||
|
||
if (timerID != null) {
|
||
console.timeEnd(timerID);
|
||
}
|
||
|
||
console.log('');
|
||
};
|