Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clear-trace

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-trace - npm Package Compare versions

Comparing version 0.0.5 to 0.0.7

35

dist/index.js

@@ -13,10 +13,14 @@ 'use strict';

var _stackTrace = require('stack-trace');
var _stackTrace2 = _interopRequireDefault(_stackTrace);
var _isAbsolute = require('is-absolute');
var _isAbsolute2 = _interopRequireDefault(_isAbsolute);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _subdir = require('subdir');

@@ -26,10 +30,2 @@

var _stackTrace = require('stack-trace');
var _stackTrace2 = _interopRequireDefault(_stackTrace);
var _isAbsolute = require('is-absolute');
var _isAbsolute2 = _interopRequireDefault(_isAbsolute);
exports['default'] = function (err, options) {

@@ -43,15 +39,20 @@ if (!err || !err.stack) {

return '\n' + _chalk2['default'].red(err.message) + '\n' + _stackTrace2['default'].parse(err).map(function (call) {
return '\n' + (0, _chalk.red)(err.message) + '\n' + _stackTrace2['default'].parse(err).map(function (call) {
if ((0, _lodashIsstring2['default'])(call.fileName)) {
var absolute = (0, _isAbsolute2['default'])(call.fileName);
if (absolute && (0, _subdir2['default'])(options.cwd, call.fileName) && !(0, _subdir2['default'])(_path2['default'].join(options.cwd, 'node_modules'), call.fileName)) {
if (absolute && (0, _subdir2['default'])(options.cwd, call.fileName) && !(0, _subdir2['default'])((0, _path.join)(options.cwd, 'node_modules'), call.fileName)) {
return (call.functionName ? _chalk2['default'].gray(' at ') + call.functionName : ' ') + _chalk2['default'].gray(' in ') + _path2['default'].join('./', _path2['default'].relative(options.cwd, call.fileName)) + (call.lineNumber ? _chalk2['default'].gray(':' + call.lineNumber + ':' + call.columnNumber) : '');
// absolute and within CWD (but not in node_modules folder)
// - highlight this line
return (call.functionName ? (0, _chalk.gray)(' at ') + call.functionName : ' ') + (0, _chalk.gray)(' in ') + (0, _path.join)('./', (0, _path.relative)(options.cwd, call.fileName)) + (call.lineNumber ? (0, _chalk.gray)(':' + call.lineNumber + ':' + call.columnNumber) : '');
} else {
return _chalk2['default'].gray((call.functionName ? ' at ' + call.functionName : ' ') + ' in ' + _path2['default'].relative(options.cwd, call.fileName) + (call.lineNumber ? ':' + call.lineNumber + ':' + call.columnNumber : ''));
// anywhere else - dim this line
return (0, _chalk.gray)((call.functionName ? ' at ' + call.functionName : ' ') + ' in ' + (0, _path.relative)(options.cwd, call.fileName) + (call.lineNumber ? ':' + call.lineNumber + ':' + call.columnNumber : ''));
}
}
return _chalk2['default'].gray((call.functionName ? ' at ' + call.functionName : ' ') + ' in [unknown]');
// no filename - dim this line
return (0, _chalk.gray)((call.functionName ? ' at ' + call.functionName : ' ') + ' in [unknown]');
}).join('\n');

@@ -58,0 +59,0 @@ };

{
"name": "clear-trace",
"description": "Function to get a more readable stack trace.",
"version": "0.0.5",
"version": "0.0.7",
"author": "Callum Locke",

@@ -10,4 +10,4 @@ "bugs": {

"dependencies": {
"chalk": "^1.0.0",
"is-absolute": "^0.1.7",
"chalk": "^1.1.0",
"is-absolute": "^0.2.0",
"lodash.isstring": "^3.0.1",

@@ -18,5 +18,5 @@ "stack-trace": "^0.0.9",

"devDependencies": {
"babel": "^5.5.8",
"babel-eslint": "^3.1.17",
"eslint": "^0.23.0",
"babel": "^5.6.14",
"babel-eslint": "^3.1.23",
"eslint": "^0.24.0",
"nodemon": "^1.3.7"

@@ -23,0 +23,0 @@ },

import isString from 'lodash.isstring';
import path from 'path';
import chalk from 'chalk';
import subdir from 'subdir';
import stackTrace from 'stack-trace';
import isAbsolute from 'is-absolute';
import {join, relative} from 'path';
import {red, gray} from 'chalk';
import subdir from 'subdir';

@@ -17,3 +17,3 @@

return '\n' + chalk.red(err.message) + '\n' + stackTrace.parse(err).map(call => {
return '\n' + red(err.message) + '\n' + stackTrace.parse(err).map(call => {
if (isString(call.fileName)) {

@@ -25,14 +25,18 @@ const absolute = isAbsolute(call.fileName);

subdir(options.cwd, call.fileName) &&
!subdir(path.join(options.cwd, 'node_modules'), call.fileName)) {
!subdir(join(options.cwd, 'node_modules'), call.fileName)) {
// absolute and within CWD (but not in node_modules folder)
// - highlight this line
return (
(call.functionName ? chalk.gray(' at ') + call.functionName : ' ') +
chalk.gray(' in ') + path.join('./', path.relative(options.cwd, call.fileName)) +
(call.lineNumber ? chalk.gray(':' + call.lineNumber + ':' + call.columnNumber) : '')
(call.functionName ? gray(' at ') + call.functionName : ' ') +
gray(' in ') + join('./', relative(options.cwd, call.fileName)) +
(call.lineNumber ? gray(':' + call.lineNumber + ':' + call.columnNumber) : '')
);
}
else {
return chalk.gray(
// anywhere else - dim this line
return gray(
(call.functionName ? ' at ' + call.functionName : ' ') +
' in ' + path.relative(options.cwd, call.fileName) +
' in ' + relative(options.cwd, call.fileName) +
(call.lineNumber ? ':' + call.lineNumber + ':' + call.columnNumber : '')

@@ -43,3 +47,4 @@ );

return chalk.gray(
// no filename - dim this line
return gray(
(call.functionName ? ' at ' + call.functionName : ' ') +

@@ -46,0 +51,0 @@ ' in [unknown]'

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc