UNPKG

snips-sam

Version:

The Snips Assistant Manager

80 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const ora = require('ora')(''); const chalk_1 = require("chalk"); class Stream { constructor(output) { this.tab = ''; this.output = output; } loading(text) { ora.text = text; ora.start(); } update(text) { ora.text = text; } stop() { ora.stopAndPersist(); } stopAndClear() { ora.stop(); } success(text, fullColor = false) { ora.succeed(fullColor && (text !== undefined) ? chalk_1.default.green(text) : text); } successNoCheck(text) { this.println(chalk_1.default.green(text)); } done(appendDone = true) { if (ora.text) { ora.stop(); if (appendDone) { this.println(`${ora.text} done`); } else { this.println(`${ora.text}`); } } else { ora.stopAndPersist(); } } ok(text) { ora.stopAndPersist({ text: `[OK] ${text}` }); } error(text, fullColor = true) { if (text === undefined) { ora.fail(undefined); } else { ora.fail(fullColor ? chalk_1.default.red(text) : text); } } errorPlain(text) { this.println(chalk_1.default.red(`${text}`)); } warning(text) { this.println(chalk_1.default.yellow(`${text}`)); } hint(text) { this.output.write(`${chalk_1.default.blue('i')} ${text} \n`); } println(text) { if (text === undefined) { this.output.write('\n'); return; } const indented = text.split('\n').map(l => this.tab + l).join('\n'); this.output.write(`${indented} \n`); } print(text) { const indented = text.split('\n').map(l => this.tab + l).join('\n'); this.output.write(indented); } log(tag, text) { this.println(`[${tag}] ${text}`); } } exports.Stream = Stream; //# sourceMappingURL=stream.js.map