From f9dccf1710dcd177f8b9adbfb35c5a53fbc8b827 Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Tue, 3 Dec 2024 12:09:48 +0300 Subject: [PATCH] fix: Fix translation compose step --- src/commands/translate/commands/compose.ts | 4 ++-- src/logger/index.ts | 16 ++++++++-------- src/program/base.ts | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/commands/translate/commands/compose.ts b/src/commands/translate/commands/compose.ts index fe17914f..c62f643e 100644 --- a/src/commands/translate/commands/compose.ts +++ b/src/commands/translate/commands/compose.ts @@ -148,7 +148,7 @@ function pipeline( output: string, {useSource, useExperimentalParser}: ComposeOptions, ) { - return async (file: FileInfo) => { + return async function pipeline(file: FileInfo) { const skeleton = new FileLoader(join(input, file.skl)); const xliff = new FileLoader(join(input, file.xliff)); @@ -156,7 +156,7 @@ function pipeline( const content = new FileLoader(join(output, file.path)); const {schemas, ajvOptions} = await resolveSchemas({ - content: content.data, + content: skeleton.data, path: file.path, }); diff --git a/src/logger/index.ts b/src/logger/index.ts index 6547c1ba..43fa6e77 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -192,14 +192,6 @@ export class Logger implements LogConsumer { return this; } - stat(): Record { - return { - [LogLevel.INFO]: this[INFO].count, - [LogLevel.WARN]: this[WARN].count, - [LogLevel.ERROR]: this[ERROR].count, - }; - } - [Write](level: LogLevels, message: string) { if (this.options.quiet) { return; @@ -228,3 +220,11 @@ function extractMessage(error: unknown): string { return String(error); } + +export function stats(logger: Logger) { + return { + [LogLevel.INFO]: logger[INFO].count, + [LogLevel.WARN]: logger[WARN].count, + [LogLevel.ERROR]: logger[ERROR].count, + }; +} diff --git a/src/program/base.ts b/src/program/base.ts index 1d0ba523..8d42ba7e 100644 --- a/src/program/base.ts +++ b/src/program/base.ts @@ -3,7 +3,7 @@ import type {Command, Config, ExtendedOption} from '~/config'; import {AsyncSeriesWaterfallHook, Hook, HookMap, SyncHook} from 'tapable'; import {isAbsolute, resolve} from 'node:path'; import {once} from 'lodash'; -import {Logger} from '~/logger'; +import {Logger, stats} from '~/logger'; import log from '@diplodoc/transform/lib/log'; import { resolveConfig, @@ -152,7 +152,7 @@ export const BaseProgram = < } private async post() { - const stat = this.logger.stat(); + const stat = stats(this.logger); if (stat.error || (this.config.strict && stat.warn)) { throw new HandledError('There is some processing errors.'); }