Skip to content

Commit

Permalink
chore: add extract translations job to check workflow and add a wrapp…
Browse files Browse the repository at this point in the history
…er to exit on extract error
  • Loading branch information
RyukTheCoder committed Oct 16, 2024
1 parent 3655637 commit 99bb357
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
env:
REF: ${{ github.ref }}

- name: Extract new translations to check if any error exists
run: node ./scripts/lingui/command.js extract --clean

- name: Test
run: |
node ./scripts/build-libs/command.mjs
Expand Down
19 changes: 19 additions & 0 deletions scripts/lingui/command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Wrapper around lingui command that exits with a non zero value if an error is detected. Lingui commands do not fail with a non-zero exit code in some cases. There is an open issue here: https://github.com/lingui/js-lingui/issues/1419
const { exec } = require('child_process');

const args = process.argv.splice(2);
const command = `yarn lingui ${args.join(' ')}`;

const handleLinguiCommand = function (error, stdout, stderr) {
if (error) {
// Handle exec command error (lingui command not found?)
console.log(`error: ${error}`);
throw error;
}
// Display command standard output
console.log(`stdout: ${stdout}`);
// Display command standard error
console.log(`stderr: ${stderr}`);
process.exit(!!stderr ? 1 : 0);
};
exec(command, handleLinguiCommand);

0 comments on commit 99bb357

Please sign in to comment.