Skip to content
Permalink
Browse files

Prevent accidental i18n overwrites during runtime

  • Loading branch information...
bkimminich committed Sep 3, 2019
1 parent bcabf7b commit a087bf906f8e95dfc366478659dab1e8e081bc1e
@@ -8,6 +8,9 @@ uploads/complaints/*.*
!uploads/complaints/.gitkeep
ftp/legal.md
package-lock.json
i18n/*.json
!frontend/src/assets/i18n/*.json
!data/static/i18n/*.json

# Build
.nyc_output/
@@ -3,5 +3,5 @@ files:
source: /frontend/src/assets/i18n/en.json
translation: /frontend/src/assets/i18n/%locale_with_underscore%.json
-
source: /i18n/en.json
translation: /i18n/%locale_with_underscore%.json
source: /data/static/i18n/en.json
translation: /data/static/i18n/%locale_with_underscore%.json
File renamed without changes.
No changes.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,9 +1,19 @@
const glob = require('glob')
const path = require('path')
const fs = require('fs-extra')

const restoreOverwrittenFilesWithOriginals = () => {
fs.copyFileSync(path.resolve(__dirname, '../../data/static/legal.md'), path.resolve(__dirname, '../../ftp/legal.md'))
fs.copyFileSync(path.resolve(__dirname, '../../data/static/JuiceShopJingle.vtt'), path.resolve(__dirname, '../../frontend/dist/frontend/assets/public/videos/JuiceShopJingle.vtt'))
glob(path.join(__dirname, '../../data/static/i18n/*.json'), (err, files) => {
if (err) {
logger.warn('Error listing JSON files in /data/static/i18n folder: ' + err.message)
} else {
files.forEach(filename => {
fs.writeFileSync(filename, path.resolve(__dirname, '../../i18n/' + filename))
})
}
})
}

module.exports = restoreOverwrittenFilesWithOriginals

0 comments on commit a087bf9

Please sign in to comment.
You can’t perform that action at this time.