From 128f3e237daef838e18e73818fc681609e4bc131 Mon Sep 17 00:00:00 2001 From: orangain Date: Mon, 1 Mar 2021 21:02:02 +0900 Subject: [PATCH] fix: Report correct number of missing messages in strict mode (#992) --- packages/cli/src/lingui-compile.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/lingui-compile.ts b/packages/cli/src/lingui-compile.ts index b81111a00..75520294c 100644 --- a/packages/cli/src/lingui-compile.ts +++ b/packages/cli/src/lingui-compile.ts @@ -58,9 +58,12 @@ function command(config: LinguiConfig, options) { ) if (!options.allowEmpty) { - const missing = R.values(messages) + const missingMsgIds = R.pipe( + R.pickBy(R.isNil), + R.keys, + )(messages) - if (missing.some(R.isNil)) { + if (missingMsgIds.length > 0) { console.error( chalk.red( `Error: Failed to compile catalog for locale ${chalk.bold( @@ -71,9 +74,9 @@ function command(config: LinguiConfig, options) { if (options.verbose) { console.error(chalk.red("Missing translations:")) - missing.forEach((msgId) => console.log(msgId)) + missingMsgIds.forEach((msgId) => console.log(msgId)) } else { - console.error(chalk.red(`Missing ${missing.length} translation(s)`)) + console.error(chalk.red(`Missing ${missingMsgIds.length} translation(s)`)) } console.error() process.exit(1)