Skip to content

Commit

Permalink
fix: Fix translation compose step
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Dec 3, 2024
1 parent 1b756af commit f9dccf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/commands/translate/commands/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ 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<string>(join(input, file.xliff));

await Promise.all([skeleton.load(), xliff.load()]);

const content = new FileLoader(join(output, file.path));
const {schemas, ajvOptions} = await resolveSchemas({
content: content.data,
content: skeleton.data,
path: file.path,
});

Expand Down
16 changes: 8 additions & 8 deletions src/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,6 @@ export class Logger implements LogConsumer {
return this;
}

stat(): Record<LogLevels, number> {
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;
Expand Down Expand Up @@ -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,
};
}
4 changes: 2 additions & 2 deletions src/program/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.');
}
Expand Down

0 comments on commit f9dccf1

Please sign in to comment.