pug-site-core 2.0.5 → 2.0.6
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/lib/generate.js +7 -8
- package/package.json +2 -2
package/lib/generate.js
CHANGED
|
@@ -44,7 +44,7 @@ export async function compilePagesPugToFn(pugPath) {
|
|
|
44
44
|
pagesPugFilePathArr.filter(
|
|
45
45
|
(fileName) => !pugPath || pathIsSame(pugPath, fileName)
|
|
46
46
|
),
|
|
47
|
-
|
|
47
|
+
12, // 限制并发数为10
|
|
48
48
|
async (fileName) => {
|
|
49
49
|
const filePath = paths.resolveRoot(paths.template.pages, fileName);
|
|
50
50
|
const funName = fileName.split(pathSymbol).join("_").slice(0, -4);
|
|
@@ -201,7 +201,7 @@ export async function fetchDataToJsonFile(args) {
|
|
|
201
201
|
// 创建一个全局任务队列控制整体并发数
|
|
202
202
|
const queue = async.queue(async (task) => {
|
|
203
203
|
await task();
|
|
204
|
-
}, fetchDataConcurrencyLimit ||
|
|
204
|
+
}, fetchDataConcurrencyLimit || 12);
|
|
205
205
|
|
|
206
206
|
// 收集所有需要执行的任务
|
|
207
207
|
const allTasks = [];
|
|
@@ -260,8 +260,8 @@ export async function fetchDataToJsonFile(args) {
|
|
|
260
260
|
const regex = /^\[.+\]$/;
|
|
261
261
|
if (regex.test(name)) {
|
|
262
262
|
let property = name.slice(1, -1);
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
// 使用async.eachLimit替换for循环,并发写入
|
|
264
|
+
await async.eachLimit(data, 12, async (dataItem, index) => {
|
|
265
265
|
let fileName = dataItem[property];
|
|
266
266
|
if (!fileName) {
|
|
267
267
|
return Promise.reject(
|
|
@@ -274,7 +274,7 @@ export async function fetchDataToJsonFile(args) {
|
|
|
274
274
|
paths.join(language, outPutPath.replace(name, fileName)),
|
|
275
275
|
dataItem
|
|
276
276
|
);
|
|
277
|
-
}
|
|
277
|
+
});
|
|
278
278
|
} else {
|
|
279
279
|
await saveJsonData(paths.join(language, outPutPath), data);
|
|
280
280
|
}
|
|
@@ -304,8 +304,7 @@ export async function fetchDataToJsonFile(args) {
|
|
|
304
304
|
let data = await getData[funName](language);
|
|
305
305
|
await checkData(data, language, funName);
|
|
306
306
|
if (Array.isArray(data)) {
|
|
307
|
-
|
|
308
|
-
const item = data[index];
|
|
307
|
+
await async.eachLimit(data, 12, async (item, index) => {
|
|
309
308
|
let lastJsonFilePath;
|
|
310
309
|
if (item.page_name) {
|
|
311
310
|
lastJsonFilePath = paths.join(
|
|
@@ -323,7 +322,7 @@ export async function fetchDataToJsonFile(args) {
|
|
|
323
322
|
}
|
|
324
323
|
item._template = fileName;
|
|
325
324
|
await saveJsonData(lastJsonFilePath, item);
|
|
326
|
-
}
|
|
325
|
+
});
|
|
327
326
|
} else {
|
|
328
327
|
if (data.page_name) {
|
|
329
328
|
jsonFilePath = paths.join(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pug-site-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"axios": "^1.7.7"
|
|
38
38
|
},
|
|
39
39
|
"license": "ISC",
|
|
40
|
-
"description": "
|
|
40
|
+
"description": "优化并发写入json文件",
|
|
41
41
|
"files": [
|
|
42
42
|
"lib/",
|
|
43
43
|
"index.js"
|