Skip to content

Commit

Permalink
🎨 misc
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Apr 5, 2024
1 parent 0785d3b commit cd5be02
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions yaml-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @Author : frostime
* @Date : 2024-04-05 21:27:55
* @FilePath : /yaml-plugin.js
* @LastEditTime : 2024-04-05 21:58:22
* @Description : 去妮玛的 json i18n,我就是要用 yaml
* @LastEditTime : 2024-04-05 22:15:49
* @Description : 去妮玛的 json 格式,我就是要用 yaml 写 i18n
*/
// plugins/vite-plugin-parse-yaml.js
import fs from 'fs';
Expand All @@ -23,7 +23,7 @@ export default function vitePluginYamlI18n(options = {}) {
return {
name: 'vite-plugin-yaml-i18n',
buildStart() {
console.log('🌈 解析 I18n: YAML to JSON..');
console.log('🌈 Parse I18n: YAML to JSON..');
const i18nPath = finalOptions.inDir;
const outputPath = finalOptions.outDir

Expand All @@ -39,7 +39,7 @@ export default function vitePluginYamlI18n(options = {}) {
const jsonFile = file.replace(/\.(yaml|yml)$/, '.json');
if (files.includes(jsonFile)) {
console.log(`---- File ${jsonFile} already exists, skipping...`);
// continue;
continue;
}
try {
const filePath = resolve(i18nPath, file);
Expand All @@ -50,7 +50,7 @@ export default function vitePluginYamlI18n(options = {}) {
console.log(`---- Writing to ${outputFilePath}`);
fs.writeFileSync(outputFilePath, jsonContent);
} catch (error) {
this.error(`Error parsing YAML file ${file}: ${error.message}`);
this.error(`---- Error parsing YAML file ${file}: ${error.message}`);
}
}
}
Expand Down

0 comments on commit cd5be02

Please sign in to comment.