1
0
mirror of synced 2025-12-22 19:34:15 -05:00
Files
docs/script/reset-known-broken-translation-files.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

59 lines
1.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
import xDotenv from 'dotenv'
import xGithub from './helpers/github.js'
import { promisify } from 'util'
import xChildProcess from 'child_process'
xDotenv.config()
const github = xGithub()
const exec = promisify(xChildProcess.exec)
// Check for required PAT
if (!process.env.GITHUB_TOKEN) {
console.error('Error! You must have a GITHUB_TOKEN set in an .env file to run this script.')
process.exit(1)
}
// [start-readme]
//
// Use this script as part of the Crowdin merge process to get the list of known broken
// files and run script/reset-translated-file.js on them.
//
// [end-readme]
main()
async function main() {
// Get body text of OP from https://github.com/github/localization-support/issues/489.
const {
data: { body },
} = await github.issues.get({
owner: 'github',
repo: 'localization-support',
issue_number: '489',
})
// Get the list of broken files from the body text.
const brokenFiles = body.replace(/^[\s\S]*?## List of Broken Translations/m, '').trim()
// Turn it into a simple array of files.
const brokenFilesArray = brokenFiles.split('\n').map((line) => line.replace('- [ ] ', '').trim())
// Run the script to revert them.
await Promise.all(
brokenFilesArray.map(async (file) => {
console.log(`resetting ${file}`)
await exec(`script/reset-translated-file.js --prefer-main ${file}`)
})
)
// Print a message with next steps.
console.log(`
Success!
Verify changes with git status and then run:
git commit --no-verify -m "Reset broken translated files to English"
`)
}