mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
wiki
This commit is contained in:
1 parent
649f65b17d
commit
e3bbff7e11
22 files changed
+315
-441
No files matched your search
@@ -1,4 +1,6 @@
|
||||
/* eslint-disable import/no-dynamic-require */
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
const fs = require('fs');
|
||||
const webpack = require('webpack');
|
||||
const yaml = require('js-yaml');
|
||||
@@ -59,12 +61,17 @@ const build = async (type) => {
|
||||
const lang = {};
|
||||
for (const j of locales) {
|
||||
const content = fs.readFileSync(root(`module/${i}/locale/${j}`)).toString();
|
||||
lang[i.split('.')[0]] = yaml.safeLoad(content);
|
||||
lang[j.split('.')[0]] = yaml.safeLoad(content);
|
||||
}
|
||||
const file = root(`.build/module/${i}/locale.json`);
|
||||
fs.writeFileSync(file, JSON.stringify(lang));
|
||||
}
|
||||
if (exist(`module/${i}/template`)) {
|
||||
if (exist(`module/${i}/template.build.js`)) {
|
||||
const builder = require(root(`module/${i}/template.build.js`));
|
||||
const [templates, exclude] = await builder.prebuild();
|
||||
const file = root(`.build/module/${i}/template.yaml`);
|
||||
fs.writeFileSync(file, yaml.safeDump(template(templates, exclude)));
|
||||
} else if (exist(`module/${i}/template`)) {
|
||||
const file = root(`.build/module/${i}/template.yaml`);
|
||||
fs.writeFileSync(file, yaml.safeDump(template(`module/${i}/template`)));
|
||||
}
|
||||
|
||||
+11
-7
@@ -15,13 +15,18 @@ function getFiles(folder) {
|
||||
return files;
|
||||
}
|
||||
|
||||
const build = (dir, exclude = []) => {
|
||||
const files = getFiles(dir);
|
||||
const templates = {};
|
||||
for (const i of files) {
|
||||
let template = fs.readFileSync(root(`${dir}/${i}`)).toString();
|
||||
const build = (dirOrObject, exclude = []) => {
|
||||
let templates = {};
|
||||
if (typeof dirOrObject === 'string') {
|
||||
const files = getFiles(dirOrObject);
|
||||
for (const i of files) {
|
||||
const template = fs.readFileSync(root(`${dirOrObject}/${i}`)).toString();
|
||||
templates[i] = template;
|
||||
}
|
||||
} else templates = dirOrObject;
|
||||
for (const i in templates) {
|
||||
if (!exclude.includes(i)) {
|
||||
template = template
|
||||
templates[i] = templates[i]
|
||||
.trim()
|
||||
.replace(/ *\n */gmi, ' ')
|
||||
.replace(/, /gmi, ',')
|
||||
@@ -35,7 +40,6 @@ const build = (dir, exclude = []) => {
|
||||
.replace(/ }}/gmi, '}}')
|
||||
.trim();
|
||||
}
|
||||
templates[i] = template;
|
||||
}
|
||||
return templates;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user