(srcLocalesDir)
| 98 | * @returns {ReturnType<typeof createTask>} |
| 99 | */ |
| 100 | export 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 | |
| 122 | export default createBundleLocalesTask(srcLocalesDir); |
no test coverage detected