Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thlorenz/trance

TRAce enhaNCEr. Adds relevant code snippets to a trace.
https://github.com/thlorenz/trance

Last synced: 13 days ago
JSON representation

TRAce enhaNCEr. Adds relevant code snippets to a trace.

Awesome Lists containing this project

README

        

# trance [![build status](https://secure.travis-ci.org/thlorenz/trance.png)](http://travis-ci.org/thlorenz/trance)

TRAce enhaNCEr. Adds relevant code snippets to a trace.

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

## Usage

```
cat trace.txt | trance

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](https://github.com/thlorenz/docme)*

## License

MIT