@vnejs/build 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/data/index.js +1 -1
- package/src/data/utils.js +8 -16
package/package.json
CHANGED
package/src/data/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const buildDataFunc = (gameDir, distDir) => {
|
|
|
12
12
|
|
|
13
13
|
result = merge(result, newData);
|
|
14
14
|
|
|
15
|
-
fs.writeFileSync(path.join(distDir, `media.${modDir}.json`), JSON.stringify(newData.data.media));
|
|
15
|
+
newData.data.media && fs.writeFileSync(path.join(distDir, `media.${modDir}.json`), JSON.stringify(newData.data.media));
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
Object.keys(result.label).forEach((label) => fs.writeFileSync(path.join(distDir, `label.${label}.json`), JSON.stringify(result.label[label])));
|
package/src/data/utils.js
CHANGED
|
@@ -50,16 +50,18 @@ const parseLines = (lines) => {
|
|
|
50
50
|
.forEach((line) => {
|
|
51
51
|
if (keyReg.test(line)) {
|
|
52
52
|
const { key } = line.match(keyReg).groups;
|
|
53
|
-
|
|
53
|
+
const indent = line.length - line.trim().length;
|
|
54
|
+
|
|
55
|
+
if (curKeys.length && curKeys[curKeys.length - 1].indent >= indent) curKeys = curKeys.filter((k) => indent < k.indent);
|
|
56
|
+
|
|
57
|
+
return curKeys.push({ key, indent });
|
|
54
58
|
} else if (keyValueReg.test(line)) {
|
|
55
59
|
const { key, value } = line.match(keyValueReg).groups;
|
|
56
60
|
|
|
57
61
|
curKeys = curKeys.filter(({ indent } = {}) => indent < line.length - line.trim().length);
|
|
58
62
|
|
|
59
63
|
const args = curKeys.reduce((acc, { key }) => {
|
|
60
|
-
if (!acc[key]) {
|
|
61
|
-
acc[key] = {};
|
|
62
|
-
}
|
|
64
|
+
if (!acc[key]) acc[key] = {};
|
|
63
65
|
return acc[key];
|
|
64
66
|
}, realLines[realLines.length - 1].args);
|
|
65
67
|
|
|
@@ -67,11 +69,7 @@ const parseLines = (lines) => {
|
|
|
67
69
|
} else {
|
|
68
70
|
curKeys = [];
|
|
69
71
|
const realLine = line.trim();
|
|
70
|
-
realLines.push({
|
|
71
|
-
line: realLine,
|
|
72
|
-
indent: line.length - realLine.length,
|
|
73
|
-
args: {},
|
|
74
|
-
});
|
|
72
|
+
realLines.push({ line: realLine, indent: line.length - realLine.length, args: {} });
|
|
75
73
|
}
|
|
76
74
|
});
|
|
77
75
|
|
|
@@ -117,8 +115,6 @@ const runBuildData = ({ modDir } = {}) => {
|
|
|
117
115
|
curLine++;
|
|
118
116
|
}
|
|
119
117
|
|
|
120
|
-
// fs.writeFileSync(path.join(rootDir, "dist", "data.json"), JSON.stringify({ media }));
|
|
121
|
-
|
|
122
118
|
let curLabel2 = null;
|
|
123
119
|
|
|
124
120
|
const kek = lines.reduce((acc, line) => {
|
|
@@ -137,11 +133,7 @@ const runBuildData = ({ modDir } = {}) => {
|
|
|
137
133
|
}, {});
|
|
138
134
|
|
|
139
135
|
Object.keys(kek).map(async (label) => {
|
|
140
|
-
const minIndent = kek[label].reduce(
|
|
141
|
-
(acc, k) => Math.min(acc, k.length ? k.length - k.trim().length : 9999),
|
|
142
|
-
9999
|
|
143
|
-
);
|
|
144
|
-
// const maxIndent = kek[label].reduce((acc, k) => Math.max(acc, k.length - k.trim().length), -9999);
|
|
136
|
+
const minIndent = kek[label].reduce((acc, k) => Math.min(acc, k.length ? k.length - k.trim().length : 9999), 9999);
|
|
145
137
|
const lines = kek[label].map((a) => a.slice(minIndent)).filter(Boolean);
|
|
146
138
|
result.label[label] = { lines: parseLines(lines) };
|
|
147
139
|
});
|