Update "generatei18nResources" script to commit changes
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
import {
|
import {
|
||||||
fetchWeblateLanguageStats,
|
fetchWeblateLanguageStats,
|
||||||
getWeblateLanguageStatsFor,
|
getWeblateLanguageStatsFor,
|
||||||
@@ -16,7 +17,9 @@ import {
|
|||||||
import { WeblateLanguageStatistic } from './Weblate.types.ts';
|
import { WeblateLanguageStatistic } from './Weblate.types.ts';
|
||||||
import { TRANSLATED_PERCENT_THRESHOLD } from './Weblate.constants.ts';
|
import { TRANSLATED_PERCENT_THRESHOLD } from './Weblate.constants.ts';
|
||||||
|
|
||||||
const outputFilePath = path.join(import.meta.dirname, '../../../src/i18n/index.ts');
|
const FILE_PATH = 'src/i18n/index.ts';
|
||||||
|
|
||||||
|
const outputFilePath = path.join(import.meta.dirname, `../../../${FILE_PATH}`);
|
||||||
const resourcesDirPath = path.join(import.meta.dirname, '../../../public/locales');
|
const resourcesDirPath = path.join(import.meta.dirname, '../../../public/locales');
|
||||||
|
|
||||||
const extractLanguageCode = (resourceFileNames: string): string =>
|
const extractLanguageCode = (resourceFileNames: string): string =>
|
||||||
@@ -57,6 +60,19 @@ const generateResources = async () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
fs.writeFileSync(outputFilePath, updatedFileContent);
|
fs.writeFileSync(outputFilePath, updatedFileContent);
|
||||||
|
|
||||||
|
execSync('yarn tsc', { stdio: 'inherit' });
|
||||||
|
|
||||||
|
execSync(`yarn eslint --fix ${FILE_PATH}`, { stdio: 'inherit' });
|
||||||
|
|
||||||
|
const hasFileChanged = execSync('git status --porcelain').toString().includes(FILE_PATH);
|
||||||
|
if (!hasFileChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
execSync('git reset');
|
||||||
|
execSync(`git add ${FILE_PATH}`);
|
||||||
|
execSync('git commit -m "Update available languages"');
|
||||||
};
|
};
|
||||||
|
|
||||||
generateResources();
|
generateResources();
|
||||||
|
|||||||
Reference in New Issue
Block a user