🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@oclif/core

Package Overview
Dependencies
Maintainers
2
Versions
470
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/core - npm Package Compare versions

Comparing version
4.11.5
to
4.11.6
+2
-1
lib/errors/errors/pretty-print.d.ts

@@ -7,3 +7,4 @@ import { PrettyPrintableError } from '../../interfaces/errors';

export declare function applyPrettyPrintOptions(error: Error, options: PrettyPrintableError): PrettyPrintableError;
export default function prettyPrint(error: Error & PrettyPrintableError & CLIErrorDisplayOptions): string | undefined;
type CombinedErrorType = Error & PrettyPrintableError & CLIErrorDisplayOptions;
export default function prettyPrint(error: CombinedErrorType): string | undefined;
export {};

@@ -32,21 +32,37 @@ "use strict";

};
function isCombinedErrorType(obj) {
return Boolean(obj) && 'name' in obj && 'message' in obj;
}
function prettyPrint(error) {
if (settings_1.settings.debug) {
return error.stack;
const prettyPrintedErrors = [];
let currentError = error;
let isDeep = false;
while (isCombinedErrorType(currentError)) {
if (settings_1.settings.debug && currentError.stack) {
prettyPrintedErrors.push(`${isDeep ? 'Caused by: ' : ''}${currentError.stack}`);
}
else {
const { bang, code, message, name: errorSuffix, ref, suggestions } = currentError;
// errorSuffix is pulled from the 'name' property on CLIError
// and is like either Error or Warning
const formattedHeader = message ? `${errorSuffix || 'Error'}: ${message}` : undefined;
const formattedCode = code ? `Code: ${code}` : undefined;
const formattedSuggestions = formatSuggestions(suggestions);
const formattedReference = ref ? `Reference: ${ref}` : undefined;
const formatted = [formattedHeader, formattedCode, formattedSuggestions, formattedReference]
.filter(Boolean)
.join('\n');
let output = `${isDeep ? 'Caused by: ' : ''}${formatted}`;
output = (0, wrap_ansi_1.default)(output, screen_1.errtermwidth - 6, { hard: true, trim: false });
if (!settings_1.settings.debug) {
output = (0, indent_string_1.default)(output, 3);
output = (0, indent_string_1.default)(output, 1, { includeEmptyLines: true, indent: bang || '' });
output = (0, indent_string_1.default)(output, 1);
}
prettyPrintedErrors.push(output);
}
isDeep = true;
currentError = currentError.cause ?? null;
}
const { bang, code, message, name: errorSuffix, ref, suggestions } = error;
// errorSuffix is pulled from the 'name' property on CLIError
// and is like either Error or Warning
const formattedHeader = message ? `${errorSuffix || 'Error'}: ${message}` : undefined;
const formattedCode = code ? `Code: ${code}` : undefined;
const formattedSuggestions = formatSuggestions(suggestions);
const formattedReference = ref ? `Reference: ${ref}` : undefined;
const formatted = [formattedHeader, formattedCode, formattedSuggestions, formattedReference]
.filter(Boolean)
.join('\n');
let output = (0, wrap_ansi_1.default)(formatted, screen_1.errtermwidth - 6, { hard: true, trim: false });
output = (0, indent_string_1.default)(output, 3);
output = (0, indent_string_1.default)(output, 1, { includeEmptyLines: true, indent: bang || '' });
output = (0, indent_string_1.default)(output, 1);
return output;
return prettyPrintedErrors.join('\n');
}
{
"name": "@oclif/core",
"description": "base library for oclif CLIs",
"version": "4.11.5",
"version": "4.11.6",
"author": "Salesforce",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues",