|
7 | 7 |
|
8 | 8 | import chalk from 'chalk';
|
9 | 9 | import * as gulp from 'gulp';
|
| 10 | +import * as moment from 'moment'; |
10 | 11 | import ConfigManager, { Config, IConfigManager } from '../config-manager';
|
11 | 12 | import ConfigManagerProxy from '../config-manager/config-manager-proxy';
|
12 | 13 | import { ConfigQuestionnaire, QuestionnaireSubscriber } from '../config-wizard';
|
@@ -92,10 +93,25 @@ export async function provideUtilities(taskFn: AnyFunction, name: string): Promi
|
92 | 93 | const provider = await getUtilitiesProvider(name);
|
93 | 94 |
|
94 | 95 | return async function (cb) {
|
| 96 | + // Get start date |
95 | 97 | const startTime = Date.now();
|
96 |
| - await taskFn(cb, provider); |
97 |
| - const duration = (Date.now() - startTime) / 1000; |
98 |
| - provider.logger.debug(chalk.bold(`took ${duration.toFixed(1)}s`)); |
| 98 | + // Run task function and catch any errors |
| 99 | + // Provide plugin utilities and callback function |
| 100 | + try { |
| 101 | + await taskFn(cb, provider); |
| 102 | + } catch (error) { |
| 103 | + provider.logger.fatal(error.message); |
| 104 | + } |
| 105 | + // Get timestamp when task finishes |
| 106 | + const endTime = Date.now(); |
| 107 | + // Get timestamp delta and convert to seconds |
| 108 | + const duration = (endTime - startTime) / 1000; |
| 109 | + // Style duration time console log output |
| 110 | + const durationMessage = chalk.hex('#7AC0DA')(`${duration.toFixed(1)}s`); |
| 111 | + // Format timestamp |
| 112 | + const formatedTimestamp = chalk.gray(moment(endTime).format('H:mm:ss')); |
| 113 | + // Finally, output the message |
| 114 | + provider.logger.debug(`${formatedTimestamp} took ${durationMessage}`); |
99 | 115 | };
|
100 | 116 | }
|
101 | 117 |
|
|
0 commit comments