node-automator 1.4.20 → 1.4.21

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.
@@ -8,9 +8,9 @@ class SplitFileCommand extends BaseCommand {
8
8
  let { src, maxSize, numParts, dst } = this.selfData;
9
9
  src = get_fst_file(src);
10
10
  dst = get_full_path(dst, "FOLDER");
11
- maxSize = getByteSize(maxSize);
12
11
  const names = await new Promise((resolve, reject) => {
13
12
  if (maxSize) {
13
+ maxSize = getByteSize(maxSize);
14
14
  splitFile.splitFileBySize(src, maxSize, dst)
15
15
  .then((names) => {
16
16
  resolve(names);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.4.20",
3
+ "version": "1.4.21",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -32,8 +32,8 @@ function removeDuplicate(value, options) {
32
32
  value = value.map(v => {
33
33
  let raw = typeof v === "string" ? v : JSON.stringify(v);
34
34
  let repeat = seen[duplicate_map[raw]] || 0;
35
- let prefix = options.remove_duplicate_prefix && format(options.remove_duplicate_prefix, {repeat}) || "";
36
- let suffix = options.remove_duplicate_suffix && format(options.remove_duplicate_suffix, {repeat}) || "";
35
+ let prefix = options.remove_duplicate_prefix && format(options.remove_duplicate_prefix, { repeat }) || "";
36
+ let suffix = options.remove_duplicate_suffix && format(options.remove_duplicate_suffix, { repeat }) || "";
37
37
  return prefix + v + suffix;
38
38
  });
39
39
  }
@@ -274,8 +274,8 @@ function formatByValues(values, fmt, prefix) {
274
274
  });
275
275
  }
276
276
 
277
- const dayInWeeks = [ "日","一","二","三","四","五","六" ];
278
- const fullDayInWeeks = [ "星期日","星期一","星期二","星期三","星期四","星期五","星期六" ];
277
+ const dayInWeeks = ["日", "一", "二", "三", "四", "五", "六"];
278
+ const fullDayInWeeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
279
279
  /**
280
280
  * 格式化日期
281
281
  * @param {Date} date
@@ -417,7 +417,7 @@ function alignNumber(from, to, options) {
417
417
  * @param { {alignment: Alignment, paddingChar: string} } options
418
418
  */
419
419
  function alignStr(from, toNum, options) {
420
- options = Object.assign({alignment: Alignment.RIGHT, paddingChar: " "}, options);
420
+ options = Object.assign({ alignment: Alignment.RIGHT, paddingChar: " " }, options);
421
421
  let prefixNum = 0;
422
422
  let suffixNum = 0;
423
423
  from = from.toString().substr(0, toNum);
@@ -436,7 +436,7 @@ function alignStr(from, toNum, options) {
436
436
  suffixNum = Math.floor(totalOffset / 2);
437
437
  break;
438
438
  }
439
- case Alignment.RIGHT:
439
+ case Alignment.RIGHT:
440
440
  default: {
441
441
  prefixNum = totalOffset;
442
442
  break;
@@ -482,11 +482,27 @@ function formatByteSize(bytes) {
482
482
  return (bytes / KB).toFixed(2) + " KB";
483
483
  }
484
484
 
485
+ function getByteSize(formatedStr) {
486
+ formatedStr = formatedStr.toString().trim();
487
+ let bytes = 0;
488
+ if (formatedStr.match(/gb?$/i)) {
489
+ bytes = Number(formatedStr.replace(/gb?$/i, "")) * GB;
490
+ } else if (formatedStr.match(/mb?$/i)) {
491
+ bytes = Number(formatedStr.replace(/mb?$/i, "")) * MB;
492
+ } else if (formatedStr.match(/kb?$/i)) {
493
+ bytes = Number(formatedStr.replace(/kb?$/i, "")) * KB;
494
+ } else {
495
+ bytes = Number(formatedStr.replace(/b?$/i, ""));
496
+ }
497
+ return bytes;
498
+ }
499
+
500
+
485
501
  /**
486
502
  *
487
503
  * @param {string} key
488
504
  */
489
- function getDataByKeySimple(key, from) {
505
+ function getDataByKeySimple(key, from) {
490
506
  const subkeys = key.split(".");
491
507
  let val = from;
492
508
  for (const subkey of subkeys) {
@@ -517,4 +533,5 @@ module.exports = {
517
533
  escapeString,
518
534
  removeDuplicate,
519
535
  removeDuplicateObject,
536
+ getByteSize,
520
537
  };