开发者社区> 镜像站> NPM> trance
trance
TRAce enhaNCEr. Adds relevant code snippets to a trace.
Last updated 6 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install trance 
SYNC missed versions from official npm registry.

trance build status

TRAce enhaNCEr. Adds relevant code snippets to a trace.

cat trace.txt | trance -b 2 -a 2

Usage

cat trace.txt | trance <options>

  Enriches trace with relevant code snippets for the files in the trace.

OPTIONS:

  -c, --code      If this flag is supplied code snippets are included in the trace
  -b, --before    How many lines of code to include before the line shown in the trace
  -a, --after     How many lines of code to include after the line shown in the trace

  -n, --nodedir   Provides directory to the Node.js project in case traces are from a Node.js app to resolve paths
  
  -h, --help      Print this help message.

EXAMPLES:

  Include code only for the line shown in the trace

    cat trace.txt | trance -c

  Include code for the line shown in the trace and 2 lines before and 1 line after

    cat trace.txt | trance -c -b 2 -a 1

  Resolve Node.js paths for the given node path ~/dev/node, but include no code

    cat trace.txt | trance --nodedir ~/dev/node 

  Resolve Node.js paths for the given node path ~/dev/node, and include code 1 line before and 1 line after

    cat trace.txt | trance --nodedir ~/dev/node -b 1 - a 1

Installation

npm install trance

API

trance::line(line, before, after, locateFile, cb)

Resolves and highlights code matching the file location found inside the given line.
If no location and/or code could be resolved it calls back with nothing.

Parameters:
Name Type Description
line string

which hopefully contains a file location

before number

how many lines of code to include before the matching lineno

after number

how many lines of code to include after the matching lineno

locateFile function

invoked with files that have no path in order to locate them, if null, the identity function is used

cb function

called back with an error or resolved and highlighted code or nothing

Source:

trance::lines(lines, before, after, locateFile, cb)

Enhances multiple lines with code samples

Parameters:
Name Type Description
lines Array.<string>

which hopefully contain a file location

before number

how many lines of code to include before the matching lineno

after number

how many lines of code to include after the matching lineno

locateFile function

invoked with files that have no path in order to locate them, if null, the identity function is used

cb function

called back with Array.<Object> each containing { line, code }

Source:

generated with docme

License

MIT

Current Tags

  • 0.2.0                                ...           latest (6 years ago)

2 Versions

  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (4)
Dev Dependencies (1)
Dependents (0)
None