UNPKG

pnpm

Version:

Fast, disk space efficient package manager

161 lines (160 loc) 15.6 kB
{ "_args": [ [ { "raw": "stacktracey@1.2.110", "scope": null, "escapedName": "stacktracey", "name": "stacktracey", "rawSpec": "1.2.110", "spec": "1.2.110", "type": "version" }, "/home/zoltan/src/pnpm/pnpm/packages/pnpm/node_modules/@pnpm/default-reporter" ] ], "_from": "stacktracey@1.2.110", "_hasShrinkwrap": false, "_id": "stacktracey@1.2.110", "_location": "/stacktracey", "_nodeVersion": "8.15.1", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/stacktracey_1.2.110_1553277615059_0.7647168380839648" }, "_npmUser": { "name": "xpl", "email": "rocket.mind@gmail.com" }, "_npmVersion": "6.4.1", "_phantomChildren": {}, "_requested": { "raw": "stacktracey@1.2.110", "scope": null, "escapedName": "stacktracey", "name": "stacktracey", "rawSpec": "1.2.110", "spec": "1.2.110", "type": "version" }, "_requiredBy": [ "/@pnpm/default-reporter" ], "_resolved": "https://registry.npmjs.org/stacktracey/-/stacktracey-1.2.110.tgz", "_shasum": "cb6ca8011ee19b512e4393f4b0c6a6ecd38b5c56", "_shrinkwrap": null, "_spec": "stacktracey@1.2.110", "_where": "/home/zoltan/src/pnpm/pnpm/packages/pnpm/node_modules/@pnpm/default-reporter", "author": { "name": "Vitaly Gordon", "email": "rocket.mind@gmail.com" }, "bugs": { "url": "https://github.com/xpl/stacktracey/issues" }, "dependencies": { "as-table": "^1.0.36", "get-source": "^1.0.32" }, "description": "Parses call stacks. Reads sources. Clean & filtered output. Sourcemaps. Node & browsers.", "devDependencies": { "babel-cli": "^6.26.0", "chai": "^4.2.0", "coveralls": "^3.0.3", "eslint": "^4.19.1", "istanbul": "^0.4.5", "mocha": "^4.1.0", "nyc": "^13.3.0" }, "directories": {}, "dist": { "integrity": "sha512-5fl9sN0GgLfn3WBxAEkAYzGuJLJNwkaZHlmflZ3pa7L9mu78FIGxDILVUdFQd+zQKCjaf3uuYblv+IzvroobjA==", "shasum": "cb6ca8011ee19b512e4393f4b0c6a6ecd38b5c56", "tarball": "https://registry.npmjs.org/stacktracey/-/stacktracey-1.2.110.tgz", "fileCount": 15, "unpackedSize": 36488, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJclSKvCRA9TVsSAnZWagAAwbgQAItV5Ol4tlbrmtqTVg+2\nmnqlpqVnTIdGtfiTS63Yz3NGeLu99or1JN71aQib5R2kopmhLztuCgpNUCZ2\nZUuRhkTfpKDWt4L/29QtgodY78f/A6W6z3lULDJrAkI1931NkbBfev09aI8E\nr3jw9UVwNzhXQExEtrGx0xcnvXJ8LQiHZAmNjlo207d+A7P99+14/wtDNAg9\nxB5fH9XxOiBhCy/5VUobes0PCqBPm/WKXV2QPCZayy4fA7M20zVgGDbAc8Ol\nMf5O7BpuuZPaXRfj9j0YGokJ2rrIC63Zw+Kk31Yv9FiWlo21XIU+FClTDJYU\n6YrLG+R+aCUHp8frC5Wp4SiJ9U+ri49VPPg5HqmiFt+dWiie20L6FUcIg+cB\nJ+9+sKANESFaCn+o0TKLcVTTk8EmmYI3h504ElIPfc5x2w8V0HT/s7ILU9kB\nJkk+ifctN0KP9vWTRIQ6O1AuVEpg1oDhCjfXsl43Yxle2MPT0/4z+eyvCWsK\nABnmZyTuQNbU+9/BefNedXfzUimwCn63/wzBJFAUC+ovFqMGNjIZXLRX/6UK\nnFCRR7PAETZ7xYPOvgzJavLgUq+X9fnohy5gp25du6xy6xnLGuqBAUa9z3hw\nZiJUmPRRsZmcPwNX84GOEPPV5eZwxvPQMtqvTOXoM4fi6SXamz2MEK/oY44b\nJeoV\r\n=bL7L\r\n-----END PGP SIGNATURE-----\r\n" }, "gitHead": "b419400db5738ef19b02350b565227054f871d2c", "homepage": "https://xpl.github.io/stacktracey", "keywords": [ "stack", "stacktrace", "stack printer", "error printer", "print error", "print stack", "print debug trace", "debug", "trace", "parse", "print", "pretty", "callstack", "call stack", "read sources", "error", "Error.stack", "error stack", "stack parse", "call stack parsing", "stack parsing", "stack parse", "parse stack", "parse call stack", "callstack parser", "call stack parse", "parse callstack", "parse stacktrace", "parse stack trace", "error stack parse", "Error.stack parse", "stack parser", "error parser", "error trace", "trace error", "sourcemap", "call location", "source text", "source lines", "print error with sources", "show error", "handling exceptions", "exception parser", "exception printer", "custom error", "pretty print", "pretty print errors", "pretty print stack" ], "license": "Unlicense", "main": "stacktracey", "maintainers": [ { "name": "x84", "email": "igor.kroitor@gmail.com" }, { "name": "xpl", "email": "rocket.mind@gmail.com" } ], "name": "stacktracey", "optionalDependencies": {}, "readme": "# StackTracey\n\n[![Build Status](https://travis-ci.org/xpl/stacktracey.svg?branch=master)](https://travis-ci.org/xpl/stacktracey) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/cvuygb8grrvm1sdm?svg=true)](https://ci.appveyor.com/project/xpl/stacktracey) [![Coverage Status](https://coveralls.io/repos/github/xpl/stacktracey/badge.svg?branch=master)](https://coveralls.io/github/xpl/stacktracey) [![NPM](https://img.shields.io/npm/v/stacktracey.svg)](http://npmjs.com/package/stacktracey) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/xpl/stacktracey.svg)](https://scrutinizer-ci.com/g/xpl/stacktracey/?branch=master) [![dependencies Status](https://david-dm.org/xpl/stacktracey/status.svg)](https://david-dm.org/xpl/stacktracey)\n\nParses call stacks. Reads sources. Clean & filtered output. Sourcemaps. Node & browsers.\n\n## Why\n\n- [x] Simple\n- [x] Works in Node and browsers, \\*nix and Windows\n- [x] Allows hiding library calls / ad-hoc exclusion (via `// @hide` marker)\n- [x] Provides source text for call locations\n- [x] Fetches sources synchronously (even in browsers) via [get-source](https://github.com/xpl/get-source)\n- [x] Full sourcemap support\n- [x] Extracts useful information from `SyntaxError` instances\n- [x] [Pretty printing](https://github.com/xpl/stacktracey/#pretty-printing)\n <img width=\"898\" alt=\"screen shot 2017-09-27 at 16 53 46\" src=\"https://user-images.githubusercontent.com/1707/30917345-79899004-a3a4-11e7-8d48-e217e2d5e2cd.png\">\n\n## What For\n\n- [Error overlay UIs](https://github.com/xpl/panic-overlay/#how-it-looks) for easier front-end development\n- [Better error reporting](https://github.com/xpl/ololog#pretty-printing-error-instances) for Node projects\n- [Advanced logging](https://github.com/xpl/ololog#displaying-call-location) (displaying call locations)\n- Assertion printing\n\n## How To\n\n```bash\nnpm install stacktracey\n```\n\n```javascript\nStackTracey = require ('stacktracey')\n```\n\nCaptures the current call stack:\n\n```javascript\nstack = new StackTracey () // captures the current call stack\n```\n\nParses stacks from an `Error` object:\n\n```javascript\nstack = new StackTracey (error) // parses error.stack\nstack = new StackTracey (error.stack) // raw string\n```\n\nIt is an array instance:\n\n```javascript\nstack instanceof Array // returns true\nstack.length // num entries\nstack[0] // top\n```\n\n...where each item exposes:\n\n```javascript\n{\n beforeParse: <original text>,\n callee: <function name>,\n calleeShort: <shortened function name>,\n file: <full path to file>, // e.g. /Users/john/my_project/node_modules/foobar/main.js\n fileRelative: <relative path to file>, // e.g. node_modules/foobar/main.js\n fileShort: <short path to file>, // e.g. foobar/main.js\n fileName: <file name>, // e.g. main.js\n line: <line number>, // starts from 1\n column: <column number>, // starts from 1\n\n index: /* true if occured in HTML file at index page */,\n native: /* true if occured in native browser code */,\n thirdParty: /* true if occured in library code */,\n hide: /* true if marked as hidden by \"// @hide\" tag */,\n syntaxError: /* true if generated from a SyntaxError instance */\n}\n```\n\nAccessing sources:\n\n```javascript\nstack = stack.withSources // will return a copy of stack with all items supplied with sources\ntop = stack[0] // top item\n```\n\n...or:\n\n```javascript\ntop = stack.withSource (0) // supplies source for an individiual item\n```\n\n...or:\n\n```javascript\ntop = StackTracey.withSource (stack[0]) // supplies source for an individiual item\n```\n\nIt will return an item supplied with the source code info (already mapped through sourcemaps):\n\n```javascript\n{\n ... // all the previously described fields\n\n line: <original line number>,\n column: <original column number>,\n sourceFile: <original source file object>,\n sourceLine: <original source line text>\n}\n```\n\nTo learn about the `sourceFile` object, read the [get-source](https://github.com/xpl/get-source#get-source) docs.\n\n## Cleaning Output\n\n```javascript\nstack = stack.withSources.clean\n```\n\n1. Excludes locations marked with the `isThirdParty` flag (library calls)\n2. Excludes locations marked with a `// @hide` comment (user defined exclusion)\n3. Merges repeated lines (via the `.mergeRepeatedLines`)\n\nYou can augment the global `isThirdParty` predicate with new rules:\n\n```javascript\nStackTracey.isThirdParty.include (path => path.includes ('my-lib')) // paths including 'my-lib' will be marked as thirdParty\n```\n```javascript\nStackTracey.isThirdParty.except (path => path.includes ('jquery')) // jquery paths won't be marked as thirdParty\n```\n\nP.S. It is better to call `.clean` on stacks supplied with sources (i.e. after the `.withSources`), to make the `// @hide` magic work, and to make third-party recognition work by reading proper file names in case if your source is compiled from other sources (and has a sourcemap attached).\n\n## Pretty Printing\n\n```javascript\nconst prettyPrintedString = new StackTracey (error).pretty\n```\n\nIt produces a nice compact table layout (thanks to [`as-table`](https://github.com/xpl/as-table)), supplied with source lines (if available):\n\n```\nat shouldBeVisibleInStackTrace test.js:25 const shouldBeVisibleInStackTrace = () => new StackTracey ()\nat it test.js:100 const stack = shouldBeVisibleInStackTrace () \nat callFn mocha/lib/runnable.js:326 var result = fn.call(ctx); \nat run mocha/lib/runnable.js:319 callFn(this.fn); \nat runTest mocha/lib/runner.js:422 test.run(fn); \nat mocha/lib/runner.js:528 self.runTest(function(err) { \nat next mocha/lib/runner.js:342 return fn(); \nat mocha/lib/runner.js:352 next(suites.pop()); \nat next mocha/lib/runner.js:284 return fn(); \nat <anonymous> mocha/lib/runner.js:320 next(0); \n```\n\nYou can even replace the default NodeJS exception printer with this! This is how you can do it:\n\n```javascript\nprocess.on ('uncaughtException', e => { /* print the stack here */ })\nprocess.on ('unhandledRejection', e => { /* print the stack here */ })\n```\n\nBut the most simple way to achieve that is to use the [`ololog`](https://github.com/xpl/ololog/blob/master/README.md) library (that is built upon StackTracey and several other handy libraries coded by me). Check it out, [it's pretty awesome and will blow your brains out](https://github.com/xpl/ololog/blob/master/README.md) :)\n\n```javascript\nconst log = require ('ololog').handleNodeErrors ()\n\n// you can also print Errors by simply passing them to the log() function\n```\n\n<img width=\"1066\" alt=\"screen shot 2018-05-11 at 19 51 03\" src=\"https://user-images.githubusercontent.com/1707/39936393-ffd529c2-5554-11e8-80f8-eff1229017c4.png\">\n\n### Overriding Max Column Widths in Pretty Printed Tables\n\nIf you get your pretty printed tables undesirably trimmed, you can try changing these numbers:\n\n```javascript\nStackTracey.maxColumnWidths = {\n\n callee: 30,\n file: 40,\n sourceLine: 80\n}\n```\n \n## Parsing `SyntaxError` instances\n\nFor example, when trying to `require` a file named `test_files/syntax_error.js`:\n\n```javascript\n// next line contains a syntax error (not a valid JavaScript)\nfoo->bar ()\n```\n\n...the pretty printed call stack for the error thrown would be something like:\n\n```\nat (syntax error) test_files/syntax_error.js:2 foo->bar ()\nat it test.js:184 try { require ('./test_files/syntax_error.js') }\nat runCallback timers.js:781\nat tryOnImmediate timers.js:743\nat processImmediate [as _immediat timers.js:714\n```\n\n...where the first line is generated from parsing the raw output from the `util.inspect` call in Node. Unfortunately, this won't work in older versions of Node (v4 and below) as these versions can't provide any meaningful information for a `SyntaxError` instance.\n\n## Array Methods\n\nAll StackTracey instances expose `map`, `filter`, `concat`, `reverse` and `slice` methods. These methods will return mapped, filtered, joined, reversed and sliced stacks, respectively:\n\n```javascript\ns = new StackTracey ().slice (1).filter (x => !x.isThirdParty) // current stack shifted by 1 and cleaned from library calls\n\ns instanceof StackTracey // true\ns instanceof Array // true\n```\n\nOther methods of the `Array` are supported too, but they will return `Array` instances, not StackTracey instances. You can convert from array via this:\n\n```javascript\nstack = new StackTracey (array)\n```\n\n..and to array via this (but generally this is not needed — you can pass around StackTracey instances as if they were real Arrays):\n\n```javascript\nArray.from (stack)\n```\n\n## Extra Stuff\n\nYou can compare two locations via this predicate (tests `file`, `line` and `column` for equality):\n\n```javascript\nStackTracey.locationsEqual (a, b)\n```\n\nResetting source cache (calls `getSource.resetCache ()` from [get-source](https://github.com/xpl/get-source)):\n\n```javascript\nStackTracey.resetCache ()\n```\n\n## Projects That Use StackTracey\n\n- [Ololog](https://github.com/xpl/ololog) — a better `console.log` for the log-driven debugging junkies!\n- [CCXT](https://github.com/ccxt-dev/ccxt) — a cryptocurrency trading library that supports 130+ exchanges\n- [pnpm](https://github.com/pnpm/pnpm) — a fast, disk space efficient package manager (faster than npm and Yarn!)\n- [panic-overlay](https://github.com/xpl/panic-overlay/) — a lightweight standalone alternative to `react-error-overlay`\n\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/xpl/stacktracey.git" }, "scripts": { "autotest": "mocha --reporter spec --watch", "babel": "babel stacktracey.js --source-maps inline --out-file ./build/stacktracey.js", "build": "npm run lint && npm run lint-test && npm run babel", "coveralls": "nyc report --reporter=text-lcov | coveralls", "lint": "eslint stacktracey.js", "lint-test": "eslint stacktracey.js", "test": "nyc --reporter=html --reporter=text mocha --reporter spec" }, "version": "1.2.110" }