-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdeleteLegacyFiles.js
More file actions
33 lines (30 loc) · 979 Bytes
/
deleteLegacyFiles.js
File metadata and controls
33 lines (30 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs')
const { reporter } = require('@dhis2/cli-helpers-engine')
/**
* @param {Object} args
* @param {string[]} args.translationFiles
* @param {string[]} args.languagesToTranslate
* @returns {void}
*/
const deleteLegacyFiles = ({ translationFiles, languagesToTransform }) => {
translationFiles.forEach((file) => {
const language = file.replace(/i18n_module_|.properties/g, '')
if (
!languagesToTransform.length ||
languagesToTransform.indexOf(language) !== -1
) {
try {
const filePathToDelete = file
fs.unlinkSync(filePathToDelete)
reporter.debug(`Deleted old file:`)
reporter.debug(`"${filePathToDelete}"`)
} catch (e) {
reporter.error('Could not delete old translation file')
reporter.error(e.message)
}
}
})
}
module.exports = {
deleteLegacyFiles,
}