@ipp/cli
Version:
An image build orchestrator for the modern web
40 lines (39 loc) • 1.34 kB
JavaScript
;
/**
* Image Processing Pipeline - Copyright (c) Marcus Cemes
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pad = exports.prettifyError = exports.BULLET = void 0;
const pretty_error_1 = __importDefault(require("pretty-error"));
const process_1 = require("process");
exports.BULLET = "\u25cf";
const MAX_ITEMS = isVerbose() ? 16 : 2;
const PADDING = 2;
const prettyError = new pretty_error_1.default().setMaxItems(MAX_ITEMS);
/** Format an error into a prettier string */
function prettifyError(err) {
return prettyError.render(err);
}
exports.prettifyError = prettifyError;
/** Indents every new line with specified padding */
function pad(text, padding = PADDING) {
return text
.split("\n")
.map((x) => (x.length > 0 ? " ".repeat(padding) + x : x))
.join("\n");
}
exports.pad = pad;
/** Scans argv for a `-v` or `--verbose` flag */
function isVerbose() {
for (const flag of ["-v", "--verbose"]) {
if (process_1.argv.indexOf(flag) !== -1)
return true;
}
return false;
}