UNPKG

totvs-dtsenv-cli

Version:

TOTVS Datasul Environment Command Line

41 lines (40 loc) 1.41 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const cliProgress = __importStar(require("cli-progress")); class ProgressBarUtils { constructor(infinityBar) { this.infinityBar = infinityBar; let options = {}; if (this.infinityBar) options = { 'clearOnComplete': true }; this.barProcess = new cliProgress.Bar(options, cliProgress.Presets.shades_classic); } start() { let self = this; let currentValue = 0; if (this.infinityBar) { self.barProcess.start(500, 0); self.intervalProcess = setInterval(function () { currentValue = currentValue + 50; if (currentValue > 500) currentValue = 0; self.barProcess.update(currentValue); }, 1000); } else self.barProcess.start(200, 0); } stop() { this.barProcess.stop(); if (this.infinityBar) clearInterval(this.intervalProcess); } } exports.default = ProgressBarUtils;