Skip to content

Instantly share code, notes, and snippets.

@EdgardoRodriguezSolano
Last active November 7, 2022 09:38
Show Gist options
  • Save EdgardoRodriguezSolano/4e9a704ceab3d2e71a107267a73e4884 to your computer and use it in GitHub Desktop.
Save EdgardoRodriguezSolano/4e9a704ceab3d2e71a107267a73e4884 to your computer and use it in GitHub Desktop.
Script to create dedicated web and ctv folders.
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