MCPcopy Index your code
hub / github.com/darkreader/darkreader / createBundleLocalesTask

Function createBundleLocalesTask

tasks/bundle-locales.js:100–120  ·  view source on GitHub ↗
(srcLocalesDir)

Source from the content-addressed store, hash-verified

98 * @returns {ReturnType<typeof createTask>}
99 */
100export function createBundleLocalesTask(srcLocalesDir) {
101 /** @type {(changedFiles: string[], watcher: any, platforms: any) => Promise<void>} */
102 const onChange = async (changedFiles, _, platforms) => {
103 const localesSrcDir = absolutePath(srcLocalesDir);
104 for (const file of changedFiles) {
105 const fileName = file.substring(file.lastIndexOf(path.sep) + 1);
106 const code = /** @type {string} */(fileName.split('.').at(-2));
107 const locale = await mergeLocale(localesSrcDir, code);
108 await writeFiles(locale, fileName, {platforms, debug: true});
109 }
110 reload.reload({type: reload.FULL});
111 };
112
113 return createTask(
114 'bundle-locales',
115 (options) => bundleLocales(srcLocalesDir, options),
116 ).addWatcher(
117 [`${srcLocalesDir}/**/*.config`],
118 onChange,
119 );
120}
121
122export default createBundleLocalesTask(srcLocalesDir);

Callers 1

bundle-locales.jsFile · 0.85

Calls 3

createTaskFunction · 0.90
bundleLocalesFunction · 0.85
addWatcherMethod · 0.80

Tested by

no test coverage detected