UNPKG

zephyr-xpack-internal

Version:

Xpack internals for Zephyr

29 lines (28 loc) • 1.04 kB
import "node:module"; import { ZephyrError, ze_log } from "zephyr-agent"; function logBuildSteps(pluginOptions, compiler) { const { pluginName } = pluginOptions; let buildStartedAt = Date.now(); compiler.hooks.beforeCompile.tapAsync(pluginName, async (params, cb)=>{ buildStartedAt = Date.now(); ze_log.init('build started at', buildStartedAt); cb(); }); compiler.hooks.failed.tap(pluginName, (err)=>{ ze_log.misc(`build failed in ${Date.now() - buildStartedAt}ms`); pluginOptions.zephyr_engine.logger.then((logger)=>{ logger({ level: 'error', action: 'build:failed', message: ZephyrError.format(err) }); }).catch((loggerError)=>{ ze_log.misc('Unable to report the failed build through the Zephyr logger:', ZephyrError.format(loggerError)); }); }); return { buildStartedAt }; } export { logBuildSteps }; //# sourceMappingURL=ze-setup-build-steps-logging.mjs.map