node-automator 1.3.0 → 1.3.1

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.
@@ -60,7 +60,7 @@ class AliOssCommand extends BaseCommand {
60
60
  let dst = this.selfData.dst;
61
61
  let src = get_full_path(this.selfData.src);
62
62
  info("");
63
- info(`开始上传 ${src} 到 ${dst}`);
63
+ info(`开始上传 ${path.basename(src)} 到 ${dst}`);
64
64
  client.put(dst, src).then((result) => {
65
65
  resolve(result);
66
66
  })
@@ -82,18 +82,17 @@ class AliOssCommand extends BaseCommand {
82
82
  let dst = path.join(dst_folder, path.relative(base, src)).replace(/\\/g, "/")
83
83
  return client.put.bind(client, dst, src);
84
84
  });
85
- queueAsync(tasks, concurrency, (done, total) => {
85
+ queueAsync(tasks, concurrency, (done, total, index, indexDone) => {
86
86
  progress(done, total, {
87
- desc: "上传中...",
87
+ desc: path.relative(base, srcs[index]) + (indexDone ? "上传中..." : "上传成功!"),
88
88
  depth: 0,
89
- color: "gray",
90
89
  });
91
90
  }).then((result) => {
92
91
  var retrySrcs = [];
93
92
  for(var i = 0; i < result.length; i++) {
94
93
  if (result[i].err) {
95
94
  retrySrcs.push(srcs[i]);
96
- warner(`上传文件 ${srcs[i]} 失败: ${result[i].err}`);
95
+ warn(`上传文件 ${path.relative(base, srcs[i])} 失败: ${result[i].err}`);
97
96
  }
98
97
  }
99
98
  if (retrySrcs.length > 0) {
@@ -521,6 +521,9 @@ function processPipe(val, pipename, pipeargs) {
521
521
  val = val.map( v => processPipe(v, pipename, pipeargs));
522
522
  } else {
523
523
  switch(pipename) {
524
+ case "ctime": {
525
+ return fs.statSync(val).ctimeMs;
526
+ }
524
527
  case "path": {
525
528
  val = get_full_path(val);
526
529
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -67,9 +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
- onProgress && onProgress(numDone, tasks.length);
71
- function checkDone() {
72
- onProgress && onProgress(numDone, tasks.length);
70
+ function checkDone(doneIndex) {
71
+ onProgress && onProgress(numDone, tasks.length, doneIndex, true);
73
72
  if (numDone == tasks.length) {
74
73
  resolve(result);
75
74
  return;
@@ -79,19 +78,21 @@ function queueAsync(tasks, limit, onProgress) {
79
78
  }
80
79
  };
81
80
  function _run() {
82
- const task = tasks[index++];
81
+ const currIndex = index++;
82
+ const task = tasks[currIndex];
83
+ onProgress && onProgress(numDone, tasks.length, currIndex, false);
83
84
  task().then(function (val) {
84
85
  numDone++;
85
86
  result.push({
86
87
  val,
87
88
  });
88
- checkDone();
89
+ checkDone(currIndex);
89
90
  }).catch(function (err) {
90
91
  numDone++;
91
92
  result.push({
92
93
  err,
93
94
  });
94
- checkDone();
95
+ checkDone(currIndex);
95
96
  });
96
97
  }
97
98
  for(var i = 0; i < tasks.length && i < limit; i++) {