Created
March 15, 2020 18:05
-
-
Save zeke/91dab5f63e592cff6826247f255573e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const { difference } = require('lodash') | |
const walk = require('walk-sync').entries | |
const languages = require('../lib/languages') | |
module.exports = function findExtraneousTranslatedFiles () { | |
const files = [] | |
const relativePaths = {} | |
// group page.relativePath lists by language | |
for (const languageCode in languages) { | |
const language = languages[languageCode] | |
const languageDir = path.join(__dirname, '..', language.dir) | |
relativePaths[languageCode] = walk(languageDir, { directories: false }) | |
.map(file => file.relativePath) | |
} | |
for (const languageCode in languages) { | |
if (languageCode === 'en') continue | |
const language = languages[languageCode] | |
/* istanbul ignore next */ | |
difference(relativePaths[languageCode], relativePaths.en).forEach(file => { | |
files.push(path.join(__dirname, '..', language.dir, file)) | |
}) | |
} | |
return files | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment