UNPKG

@unibeautify/cli

Version:
31 lines 897 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const chalk_1 = require("chalk"); class BaseCommand { constructor() { this.stdout = process.stdout; this.stderr = process.stderr; } writeOut(text) { this.stdout.write(text + "\n"); } writeOutHeading(text) { this.writeOut(this.stdout.isTTY ? chalk_1.default.blue(text) : text); } writeError(text) { this.stderr.write((this.stderr.isTTY ? chalk_1.default.red(text) : text) + "\n"); } set exitCode(exitCode) { process.exitCode = exitCode; } get exitCode() { return process.exitCode || 0; } handleError(error, exitCode) { this.writeError(error.message); this.exitCode = exitCode; return Promise.reject(error); } } exports.BaseCommand = BaseCommand; //# sourceMappingURL=BaseCommand.js.map