UNPKG

snips-sam

Version:

The Snips Assistant Manager

65 lines (64 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ora = require('ora')(''); var chalk_1 = require("chalk"); var Stream = (function () { function Stream(output) { this.tab = ' '; this.output = output; } Stream.prototype.loading = function (text) { ora.text = text; ora.start(); }; Stream.prototype.update = function (text) { ora.text = text; }; Stream.prototype.stop = function () { ora.stopAndPersist(); }; Stream.prototype.stopAndClear = function () { ora.stop(); }; Stream.prototype.success = function (text) { ora.succeed(text); }; Stream.prototype.done = function () { if (ora.text) { ora.stopAndPersist({ text: ora.text + " done" }); } else { ora.stopAndPersist(); } }; Stream.prototype.ok = function (text) { ora.stopAndPersist({ text: "[OK] " + text }); }; Stream.prototype.error = function (text) { if (!text) { ora.fail(text); } else { ora.stopAndPersist(); ora.fail(text); } }; Stream.prototype.hint = function (text) { this.output.write(chalk_1.default.yellowBright("i") + (" " + text + " \n")); }; Stream.prototype.print = function (text) { var _this = this; var indented = text.split('\n').map(function (l) { return _this.tab + l; }).join('\n'); this.output.write(indented + '\n'); }; Stream.prototype.printNoLN = function (text) { var _this = this; var indented = text.split('\n').map(function (l) { return _this.tab + l; }).join('\n'); this.output.write(indented); }; Stream.prototype.log = function (tag, text) { this.print("[" + tag + "] " + text); }; return Stream; }()); exports.Stream = Stream;