diffpx 0.0.4 → 0.0.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/runner.js +14 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diffpx",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "bin": {
5
5
  "diffpx": "bin/diffpx.js"
6
6
  },
package/src/runner.js CHANGED
@@ -46,17 +46,19 @@ function getProgress(status) {
46
46
  }
47
47
 
48
48
  async function runJob({diffpxKey, payload}) {
49
+ const initialSnapshotsTotal = Array.isArray(payload?.snapshots) ? payload.snapshots.length : 1;
50
+ const initialWidthsTotal = Array.isArray(payload?.settings?.width) ? payload.settings.width.length : 1;
51
+ const isTTY = !!process.stdout.isTTY;
49
52
  const multiBar = new cliProgress.MultiBar({
50
53
  clearOnComplete: false,
51
54
  hideCursor: true,
52
55
  barCompleteChar: '█',
53
56
  barIncompleteChar: '░',
54
- format: '{name} [{bar}] {percentage}% | {value}/{total}'
57
+ format: '{name} [{bar}] {percentage}% | {value}/{total}',
58
+ noTTYOutput: !isTTY,
59
+ notTTYSchedule: 1000
55
60
  }, cliProgress.Presets.shades_classic);
56
61
 
57
- const initialSnapshotsTotal = Array.isArray(payload?.snapshots) ? payload.snapshots.length : 1;
58
- const initialWidthsTotal = Array.isArray(payload?.settings?.width) ? payload.settings.width.length : 1;
59
-
60
62
  const snapshotsBar = multiBar.create(
61
63
  Math.max(1, initialSnapshotsTotal),
62
64
  0,
@@ -88,14 +90,17 @@ async function runJob({diffpxKey, payload}) {
88
90
  const widthLabel = normalizePxLabel(p.widthLabel) || getInitialWidthName(payload);
89
91
 
90
92
  const snapTotal = p.snapshotsTotal > 0 ? p.snapshotsTotal : Math.max(1, initialSnapshotsTotal);
91
- const snapDone = p.snapshotsTotal > 0 ? Math.min(p.snapshotsDone, p.snapshotsTotal) : snapshotsBar.value;
92
-
93
- snapshotsBar.setTotal(snapTotal);
94
- snapshotsBar.update(snapDone, {name: snapshotLabel});
93
+ const snapDone = p.snapshotsTotal > 0
94
+ ? Math.min(p.snapshotsDone, p.snapshotsTotal)
95
+ : (snapshotsBar ? snapshotsBar.value : 0);
95
96
 
96
97
  const wTotal = p.widthsTotal > 0 ? p.widthsTotal : Math.max(1, initialWidthsTotal);
97
- const wDone = p.widthsTotal > 0 ? Math.min(p.widthsDone, p.widthsTotal) : widthsBar.value;
98
+ const wDone = p.widthsTotal > 0
99
+ ? Math.min(p.widthsDone, p.widthsTotal)
100
+ : widthsBar.value;
98
101
 
102
+ snapshotsBar.setTotal(snapTotal);
103
+ snapshotsBar.update(snapDone, {name: snapshotLabel});
99
104
  widthsBar.setTotal(wTotal);
100
105
  widthsBar.update(wDone, {name: widthLabel});
101
106
  }