Skip to content

Commit

Permalink
fix: throw error if no translations were found
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Jul 13, 2024
1 parent f742d84 commit 946d6fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,6 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
omittedFilesNoSources.add(allOmittedFilesNoSources);
}

if (!anyFileDownloaded.get()) {
if (project.getSkipUntranslatedFiles() || skipUntranslatedFiles.get()) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download_skipuntranslated")));
} else {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download")));
}
}

if (!ignoreMatch && !plainView) {
totalOmittedFiles = totalOmittedFiles.entrySet().stream()
.filter(entry -> !entry.getValue().isEmpty())
Expand Down Expand Up @@ -322,6 +314,14 @@ public void act(Outputter out, PropertiesWithFiles pb, ProjectClient client) {
out.println(EMPTY.withIcon(RESOURCE_BUNDLE.getString("message.faq_link")));
}
}

if (!anyFileDownloaded.get()) {
if (project.getSkipUntranslatedFiles() || skipUntranslatedFiles.get()) {
throw new ExitCodeExceptionMapper.ValidationException(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download_skipuntranslated"));
} else {
throw new ExitCodeExceptionMapper.ValidationException(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.warning.no_file_to_download")));
}
}
} catch (ProjectBuildFailedException e) {
out.println(WARNING.withIcon(RESOURCE_BUNDLE.getString("message.translations_build_unsuccessful")));
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.crowdin.cli.commands.NewAction;
import com.crowdin.cli.commands.Outputter;
import com.crowdin.cli.commands.functionality.FilesInterface;
import com.crowdin.cli.commands.picocli.ExitCodeExceptionMapper;
import com.crowdin.cli.properties.PropertiesWithFiles;
import com.crowdin.cli.properties.NewPropertiesWithFilesUtilBuilder;
import com.crowdin.cli.properties.helper.FileHelperTest;
Expand Down Expand Up @@ -87,7 +88,8 @@ public void testEmptyProject() throws IOException, ResponseException {

NewAction<PropertiesWithFiles, ProjectClient> action =
new DownloadAction(files, false, null, null, false, null, false, false, false, false, false);
action.act(Outputter.getDefault(), pb, client);

assertThrows(ExitCodeExceptionMapper.ValidationException.class, () -> action.act(Outputter.getDefault(), pb, client));

verify(client).downloadFullProject(null);
verify(client).startBuildingTranslation(eq(buildProjectTranslationRequest));
Expand Down

0 comments on commit 946d6fe

Please sign in to comment.