@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import program from 'commander'
|
||||
import { execSync } from 'child_process'
|
||||
import { languageFiles, compareLiquidTags } from '../../lib/liquid-tags/tokens.js'
|
||||
import languages from '../../lib/languages.js'
|
||||
import fs from 'fs'
|
||||
|
||||
program
|
||||
.description('show-liquid-tags-diff')
|
||||
@@ -12,15 +12,15 @@ program
|
||||
.parse(process.argv)
|
||||
|
||||
function resetFiles(files) {
|
||||
console.log(`Files to be reset (${files.length}): \n${files.join('\n')}`)
|
||||
console.log(`Reseting ${files.length} files:`)
|
||||
|
||||
const dryRun = program.opts().dryRun ? '--dry-run' : ''
|
||||
|
||||
files.forEach((file) => {
|
||||
// remove file so it falls back to English
|
||||
console.log(`removing ${file}`)
|
||||
|
||||
if (!program.opts().dryRun) {
|
||||
fs.unlinkSync(file)
|
||||
}
|
||||
execSync(
|
||||
`script/i18n/reset-translated-file.js ${file} --reason="broken liquid tags" ${dryRun}`,
|
||||
{ stdio: 'inherit' }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,13 @@ const resetToEnglishSource = (translationFilePath) => {
|
||||
}
|
||||
|
||||
if (!dryRun) {
|
||||
// replace file with English source
|
||||
// it is important to replace the file with English source instead of
|
||||
// removing it, and relying on the fallback, because redired_from frontmatter
|
||||
// won't work in fallbacks
|
||||
const englishContent = fs.readFileSync(englishFile, 'utf8')
|
||||
fs.writeFileSync(translationFilePath, englishContent)
|
||||
}
|
||||
|
||||
console.log(
|
||||
'-> reverted to English: %s %s',
|
||||
path.relative(process.cwd(), translationFilePath),
|
||||
|
||||
Reference in New Issue
Block a user