Skip to content

Commit

Permalink
Suggest running the vocab CLI if a vocab config file is found
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Nov 20, 2024
1 parent 71ee117 commit d6845b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-bats-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': minor
---

`sku translations`: Suggest using the `vocab` CLI when `languages` is not configured and a vocab config file is detected
14 changes: 10 additions & 4 deletions packages/sku/scripts/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
watch,
'delete-unused-keys': deleteUnusedKeys,
} = require('../config/args');
const { compile, validate } = require('@vocab/core');
const { compile, validate, resolveConfig } = require('@vocab/core');
const { push, pull } = require('@vocab/phrase');
const { getVocabConfig } = require('../config/vocab/vocab');

Expand Down Expand Up @@ -43,9 +43,15 @@ const log = (message) => console.log(chalk.cyan(message));
const vocabConfig = getVocabConfig();

if (!vocabConfig) {
throw new Error(
'No "languages" configured. Please configure "languages" in your sku config before running translation commands',
);
const errorMessage =
'No "languages" configured. Please configure "languages" in your sku config before running translation commands.';

const resolvedVocabConfig = await resolveConfig();
if (resolvedVocabConfig) {
errorMessage += `\nIt looks like you have a vocab config file in ${resolvedVocabConfig.projectRoot}. Perhaps you intended to run "vocab ${translationSubCommand}" instead?`;
}

throw new Error(errorMessage);
}

if (!translationSubCommands.includes(translationSubCommand)) {
Expand Down

0 comments on commit d6845b3

Please sign in to comment.