youch-terminal
Advanced tools
Comparing version 2.2.1 to 2.2.2
19
index.js
@@ -13,4 +13,5 @@ 'use strict' | ||
const { platform, cwd } = process | ||
const { sep } = require('path') | ||
const wordwrap = require('wordwrap') | ||
const { fileURLToPath } = require('url') | ||
const { sep, relative } = require('path') | ||
const stringWidth = require('string-width') | ||
@@ -22,3 +23,13 @@ const { dim, yellow, green, red, cyan } = require('kleur') | ||
const DASH = platform === 'win32' && !process.env.WT_SESSION ? '⁃' : '⁃' | ||
const CWD = cwd() | ||
function getRelativePath(filePath) { | ||
/** | ||
* Node.js error stack is all messed up. Some lines have file info | ||
* enclosed in parenthesis and some are not | ||
*/ | ||
filePath = filePath.replace('async file:', 'file:') | ||
return relative(CWD, filePath.startsWith('file:') ? fileURLToPath(filePath) : filePath) | ||
} | ||
/** | ||
@@ -133,3 +144,3 @@ * Pulls the main frame from the frames stack | ||
function getHelpText(error, prefix) { | ||
const help = error.help | ||
let help = error.help | ||
if (!help) { | ||
@@ -176,3 +187,3 @@ return [] | ||
const filePath = displayShortPath ? frame.filePath.replace(`${cwd()}${sep}`, '') : frame.filePath | ||
const filePath = displayShortPath ? getRelativePath(frame.filePath) : frame.filePath | ||
return [`${prefix} at ${yellow(`${frameMethod(frame)}`)} ${green(filePath)}:${green(frame.line)}`] | ||
@@ -231,3 +242,3 @@ } | ||
const filePath = displayShortPath | ||
? frame.filePath.replace(`${cwd()}${sep}`, '') | ||
? getRelativePath(frame.filePath) | ||
: frame.filePath | ||
@@ -234,0 +245,0 @@ |
{ | ||
"name": "youch-terminal", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Show youch error on terminal", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8827
259