Last active
November 7, 2022 09:38
-
-
Save EdgardoRodriguezSolano/4e9a704ceab3d2e71a107267a73e4884 to your computer and use it in GitHub Desktop.
Script to create dedicated web and ctv folders.
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 fs = require('fs-extra'); | |
const { languages } = require('../config'); | |
for (let i = 0; i < languages.length; i++) { | |
const languageAbbreviation = languages[i]; | |
const dir = `src/sdk/ui/common/locale/gdpr/${languageAbbreviation}`; | |
// This file is no longer needed | |
try { | |
fs.unlinkSync(`${dir}/index.js`); | |
} catch (err) { | |
console.error( | |
`Web : An error Error while trying deleting the ${dir}/index.js file for the language ${languageAbbreviation}`, | |
); | |
} | |
// The import paths need to be updated as well | |
try { | |
fs.mkdirSync(`${dir}/web`, { recursive: true }); | |
fs.writeFileSync( | |
`${dir}/web/index.js`, | |
`/* istanbul ignore file */ | |
// Generated by the languages sdk-script script | |
import manual from '../manual.json'; | |
import onesky from '../onesky.json'; | |
import TCFLocales from '../tcf/v2/index.json'; | |
import loadUI from '../../../../../gdpr'; | |
export default loadUI(Object.assign({}, manual, onesky, TCFLocales), '${languageAbbreviation}'); | |
`, | |
); | |
} catch (err) { | |
console.error( | |
`Web : An error Error while trying to create the web/index.js file for the language ${languageAbbreviation}`, | |
); | |
} | |
// The import paths need to be updated as well | |
try { | |
fs.mkdirSync(`${dir}/ctv`, { recursive: true }); | |
fs.writeFileSync( | |
`${dir}/ctv/index.js`, | |
`/* istanbul ignore file */ | |
// Generated by the languages sdk-script script | |
import manual from '../manual.json'; | |
import onesky from '../onesky.json'; | |
import TCFLocales from '../tcf/v2/index.json'; | |
import loadUI from '../../../../../ctv'; | |
export default loadUI(Object.assign({}, manual, onesky, TCFLocales), '${languageAbbreviation}'); | |
`, | |
); | |
} catch (err) { | |
console.error( | |
`Web : An error Error while trying to create the ctv/index.js file for the language ${languageAbbreviation}`, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment