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
script:
- yarn i18n:extract
- yes | yarn i18n:push
- yarn i18n:push
artifacts:
name: "Source strings for $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA"
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;
if (publishInBranch) {
@ -336,19 +347,21 @@ async function push(): Promise<void> {
console.log(ch.green('Success'));
}
try {
const action = process.argv[2];
(async() => {
try {
const action = process.argv[2];
switch (action) {
case 'pull':
pull();
break;
case 'push':
push();
break;
default:
console.error(`Unknown action ${action}`);
switch (action) {
case 'pull':
await pull();
break;
case 'push':
await push();
break;
default:
console.error(`Unknown action ${action}`);
}
} catch (exception) {
console.error(exception);
}
} catch (exception) {
console.error(exception);
}
})();