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 authored and nikaaru committed Nov 3, 2024
1 parent 2cadeb1 commit 5ce4873
Show file tree
Hide file tree
Showing 2 changed files with 23 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
20 changes: 20 additions & 0 deletions scripts/lingui/command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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}`);
const errorExists = stderr?.trim() !== '✔';
process.exit(errorExists ? 1 : 0);
};
exec(command, handleLinguiCommand);

0 comments on commit 5ce4873

Please sign in to comment.