node-automator 1.3.10 → 1.3.12

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.
@@ -155,9 +155,9 @@ class AliOssCommand extends BaseCommand {
155
155
  timeout,
156
156
  });
157
157
  });
158
- queueAsync(tasks, concurrency, (done, total, index, indexDone) => {
158
+ queueAsync(tasks, concurrency, (done, total, index, ret) => {
159
159
  progress(done, total, {
160
- desc: path.relative(base, srcs[index]) + " " + (indexDone ? "上传结束" : "上传中..."),
160
+ desc: path.relative(base, srcs[index]) + " " + (ret ? (ret.err ? "上传失败!" : "上传成功!") : "上传中..."),
161
161
  depth: 0,
162
162
  });
163
163
  }).then((result) => {
@@ -504,6 +504,15 @@ function processPipe(val, pipename, pipeargs) {
504
504
  val = val.map(v => v[pipeargs[0]]);
505
505
  break;
506
506
  }
507
+ case "chunk": {
508
+ var ret = [];
509
+ var chunkSize = pipeargs[0] || 50;
510
+ for (var i = 0, chunkNum = Math.ceil(val.length / chunkSize); i < chunkNum; i++) {
511
+ ret.push(val.slice(i * chunkSize, (i + 1) * chunkSize));
512
+ }
513
+ val = ret;
514
+ break;
515
+ }
507
516
  case "size": {
508
517
  if (!val) {
509
518
  val = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -67,8 +67,8 @@ function queueAsync(tasks, limit, onProgress) {
67
67
  if (!tasks.length) resolve(result);
68
68
  var index = 0;
69
69
  var numDone = 0;
70
- function checkDone(doneIndex) {
71
- onProgress && onProgress(numDone, tasks.length, doneIndex, true);
70
+ function checkDone(doneIndex, ret) {
71
+ onProgress && onProgress(numDone, tasks.length, doneIndex, ret);
72
72
  if (numDone == tasks.length) {
73
73
  resolve(result);
74
74
  return;
@@ -80,19 +80,19 @@ function queueAsync(tasks, limit, onProgress) {
80
80
  function _run() {
81
81
  const currIndex = index++;
82
82
  const task = tasks[currIndex];
83
- onProgress && onProgress(numDone, tasks.length, currIndex, false);
83
+ onProgress && onProgress(numDone, tasks.length, currIndex);
84
84
  task().then(function (val) {
85
85
  numDone++;
86
86
  result.push({
87
87
  val,
88
88
  });
89
- checkDone(currIndex);
89
+ checkDone(currIndex, { val });
90
90
  }).catch(function (err) {
91
91
  numDone++;
92
92
  result.push({
93
93
  err,
94
94
  });
95
- checkDone(currIndex);
95
+ checkDone(currIndex, { err });
96
96
  });
97
97
  }
98
98
  for(var i = 0; i < tasks.length && i < limit; i++) {