Fix errors catching in i18n-crowdin script.

Detect non tty environment and apply defaults.
This commit is contained in:
ErickSkrauch 2020-06-09 22:02:41 +03:00
parent 8194f8d106
commit c3b778e3ca
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
2 changed files with 29 additions and 16 deletions

View File

@ -127,7 +127,7 @@ Crowdin push:
- .yarnCache - .yarnCache
script: script:
- yarn i18n:extract - yarn i18n:extract
- yes | yarn i18n:push - yarn i18n:push
artifacts: artifacts:
name: "Source strings for $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA" name: "Source strings for $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA"
paths: paths:

View File

@ -277,7 +277,18 @@ async function push(): Promise<void> {
}); });
} }
const { disapproveTranslates, publishInBranch = false } = await prompt(questions); let disapproveTranslates = true;
let publishInBranch = false;
try {
const answers = await prompt(questions);
disapproveTranslates = answers[0];
publishInBranch = answers[1] || false;
} catch (err) {
// okay if it's tty error
if (!err.isTtyError) {
throw err;
}
}
let branchId: number|undefined; let branchId: number|undefined;
if (publishInBranch) { if (publishInBranch) {
@ -336,19 +347,21 @@ async function push(): Promise<void> {
console.log(ch.green('Success')); console.log(ch.green('Success'));
} }
try { (async() => {
const action = process.argv[2]; try {
const action = process.argv[2];
switch (action) { switch (action) {
case 'pull': case 'pull':
pull(); await pull();
break; break;
case 'push': case 'push':
push(); await push();
break; break;
default: default:
console.error(`Unknown action ${action}`); console.error(`Unknown action ${action}`);
}
} catch (exception) {
console.error(exception);
} }
} catch (exception) { })();
console.error(exception);
}