diff --git a/src/commands/build/index.ts b/src/commands/build/index.ts index bf08189d..73f979a6 100644 --- a/src/commands/build/index.ts +++ b/src/commands/build/index.ts @@ -12,6 +12,7 @@ import {Lang, Stage, YFM_CONFIG_FILENAME} from '~/constants'; import {Command, Config, configPath, defined, valuable} from '~/config'; import {OutputFormat, options} from './config'; import {Run} from './run'; +import {handler} from './handler'; import { Templating, @@ -273,8 +274,6 @@ export class Build run.logger.pipe(this.logger); - // console.log(run.config); - shell.mkdir('-p', run.originalOutput); // Create temporary input/output folders @@ -283,7 +282,7 @@ export class Build await this.hooks.BeforeAnyRun.promise(run); await this.hooks.BeforeRun.for(this.config.outputFormat).promise(run); - await Promise.all([this.handler(run), this.hooks.Run.promise(run)]); + await Promise.all([handler(run), this.hooks.Run.promise(run)]); await this.hooks.AfterRun.for(this.config.outputFormat).promise(run); await this.hooks.AfterAnyRun.promise(run); @@ -296,14 +295,4 @@ export class Build shell.rm('-rf', run.input, run.output); } - - /** - * Loads handler in async mode to not initialise all deps on startup. - */ - private async handler(run: Run) { - // @ts-ignore - const {handler} = await import('./handler'); - - return handler(run); - } } diff --git a/src/index.ts b/src/index.ts index 8fbded19..12fed307 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,7 @@ if (require.main === module) { if (message) { // eslint-disable-next-line no-console - console.error(error.stack || error.message || error); + console.error(error.message || error); } } diff --git a/src/program/base.ts b/src/program/base.ts index 90292d5a..29364bbd 100644 --- a/src/program/base.ts +++ b/src/program/base.ts @@ -4,6 +4,7 @@ import {AsyncSeriesWaterfallHook, Hook, HookMap, SyncHook} from 'tapable'; import {isAbsolute, resolve} from 'node:path'; import {once} from 'lodash'; import {Logger} from '~/logger'; +import log from '@diplodoc/transform/lib/log'; import { resolveConfig, scope as scopeConfig, @@ -151,9 +152,13 @@ export const BaseProgram = < } private async post() { - const {error, warn} = this.logger; - if (error.count || (this.config.strict && warn.count)) { - throw new HandledError('There is some errors.'); + if (this.logger.error.count || (this.config.strict && this.logger.warn.count)) { + throw new HandledError('There is some processing errors.'); + } + + const {error, warn} = log.get(); + if (error.length || (this.config.strict && warn.length)) { + throw new HandledError('There is some processing errors.'); } }