Comparing version 0.1.0 to 0.2.0
@@ -8,2 +8,3 @@ #!/usr/bin/env node | ||
var logSymbols = require('log-symbols'); | ||
var stdin = require('get-stdin'); | ||
process.title = 'leasot'; | ||
@@ -37,17 +38,10 @@ | ||
} | ||
process.exit(1); | ||
} | ||
function parseContents(filetype, contents, file) { | ||
var todos; | ||
try { | ||
todos = leasot.parse(filetype, contents, file); | ||
} catch (e) { | ||
console.log(logSymbols.error, e.toString()); | ||
if (!leasot.isExtSupported(filetype)) { | ||
console.log(logSymbols.error, 'Filetype ' + filetype + ' is not supported.'); | ||
process.exit(1); | ||
} | ||
if (!todos.length) { | ||
console.log(logSymbols.success, 'No todos/fixmes found'); | ||
process.exit(0); | ||
} | ||
var todos = leasot.parse(filetype, contents, file); | ||
return todos; | ||
@@ -62,30 +56,27 @@ } | ||
var todos = parseContents(filetype, contents, file); | ||
if (!todos.length) { | ||
console.log(logSymbols.success, 'No todos/fixmes found'); | ||
process.exit(0); | ||
} | ||
useReporter(reporter, todos); | ||
process.exit(1); | ||
} | ||
//assume any unconsumed option is a file path | ||
var filePath = program.args; | ||
if (filePath && filePath.length) { | ||
//currently only handle 1 file | ||
//TODO: handle multiple incoming files in args | ||
var _file = filePath[0]; | ||
var _contents = fs.readFileSync(path.resolve(process.cwd(), _file), 'utf8'); | ||
function readFiles(files) { | ||
//TOOD: handle multiple files | ||
var file = files[0]; | ||
var _contents = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8'); | ||
run(_contents, { | ||
file: _file | ||
file: file | ||
}); | ||
} | ||
if (!process.stdin.isTTY) { | ||
stdin(run); | ||
return; | ||
} | ||
//get data from stream | ||
process.stdin.setEncoding('utf8'); | ||
if (process.stdin.isTTY) { | ||
if (!program.args.length) { | ||
program.help(); | ||
return; | ||
} | ||
var data = []; | ||
process.stdin.on('data', function (chunk) { | ||
data.push(chunk); | ||
}).on('end', function () { | ||
data = data.join(); | ||
run(data); | ||
}); | ||
readFiles(program.args); |
{ | ||
"name": "leasot", | ||
"version": "0.1.0", | ||
"description": "Parse and output TODOs and FIXMEs from comments in your files", | ||
"license": "MIT", | ||
"repository": "pgilad/leasot", | ||
"author": "Gilad Peleg <giladp007@gmail.com> (http://giladpeleg.com)", | ||
"bin": "./bin/leasot.js", | ||
"scripts": { | ||
"test": "mocha -R spec ./tests/*.js", | ||
"watch": "mocha -w -R spec ./tests/*.js" | ||
}, | ||
"keywords": "fixme, todo, comments, list, parse, generator, ci, productivity, automation", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"lib", | ||
"bin" | ||
], | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"dependencies": { | ||
"chalk": "^0.5.1", | ||
"commander": "^2.5.0", | ||
"get-line-from-pos": "^1.0.0", | ||
"json2xml": "^0.1.1", | ||
"lodash.compact": "^2.4.1", | ||
"lodash.defaults": "^2.4.1", | ||
"log-symbols": "^1.0.1", | ||
"text-table": "^0.2.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.0.1", | ||
"should": "^4.3.0" | ||
} | ||
"name": "leasot", | ||
"version": "0.2.0", | ||
"description": "Parse and output TODOs and FIXMEs from comments in your files", | ||
"license": "MIT", | ||
"repository": "pgilad/leasot", | ||
"author": "Gilad Peleg <giladp007@gmail.com> (http://giladpeleg.com)", | ||
"bin": "./bin/leasot.js", | ||
"scripts": { | ||
"test": "mocha -R spec ./tests/*.js", | ||
"watch": "mocha -w -R spec ./tests/*.js" | ||
}, | ||
"keywords": "fixme, todo, comments, list, parse, generator, ci, productivity, automation", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"lib", | ||
"bin" | ||
], | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"dependencies": { | ||
"commander": "^2.5.0", | ||
"get-line-from-pos": "^1.0.0", | ||
"get-stdin": "^3.0.2", | ||
"json2xml": "^0.1.1", | ||
"lodash.compact": "^2.4.1", | ||
"lodash.defaults": "^2.4.1", | ||
"log-symbols": "^1.0.1", | ||
"text-table": "^0.2.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.0.1", | ||
"should": "^4.3.0" | ||
} | ||
} |
126
README.md
@@ -11,2 +11,4 @@ # leasot | ||
![Basic output example of leasot](media/table.png) | ||
## Comment format | ||
@@ -106,2 +108,23 @@ | ||
## API | ||
```js | ||
var leasot = require('leasot'); | ||
``` | ||
`leasot` exposes the following API: | ||
### isExtSupported | ||
TODO | ||
### parse | ||
TODO | ||
### reporter | ||
TODO | ||
## Built-in Reporters | ||
@@ -117,2 +140,81 @@ | ||
### Markdown | ||
Returns a markdown version of the todos. | ||
### Options | ||
#### newLine | ||
How to separate lines in the output file. Defaults to your OS's default line separator. | ||
**Type**: `String` | ||
**Default**: `Your system default line feed` | ||
### padding | ||
How many `newLine`s should separate between comment type blocks. | ||
**Type**: `Number` | ||
**Default**: 2 | ||
**Minimum**: 0 | ||
### transformHeader(kind) | ||
Control the output of a header for each comment kind (*i.e todo, fixme*). | ||
**Type**: `Function` | ||
**Default**: | ||
```js | ||
transformHeader: function (kind) { | ||
return ['### ' + kind + 's', | ||
'| Filename | line # | ' + kind, | ||
'|:------|:------:|:------' | ||
]; | ||
} | ||
``` | ||
**kind**: will be be passed as the comment kind (todo/fixme). | ||
**Returns**: `String[]|String` | ||
You are expected to return either an `Array of strings` or just a `string`. If you return an array - each item will be separated by a newline in the output. | ||
### transformComment(file, line, text, kind) | ||
Control the output for each comment. | ||
**Type**: `Function` | ||
**Default**: | ||
```js | ||
transformComment: function (file, line, text, kind) { | ||
return ['| ' + file + ' | ' + line + ' | ' + text]; | ||
}, | ||
``` | ||
**file**: filename the comment was in. | ||
**line**: line of comment. | ||
**text**: comment text | ||
**kind**: will be be passed as the comment kind (todo/fixme). | ||
**Returns**: `String[]|String` | ||
You are expected to return either an `Array of strings` or just a `string`. If you return an array - each item will be separated by a newline in the output. | ||
### Table | ||
Returns a pretty formatted table of the todos. | ||
### Raw | ||
Just returns the raw javascript todos | ||
### JSON | ||
@@ -130,6 +232,28 @@ | ||
## API | ||
### XML | ||
Return an unformatted XML valid representation of the todos. | ||
Parsed using [json2xml](https://github.com/estheban/node-json2xml) | ||
#### Options | ||
##### header | ||
Whether to include xml header | ||
Type: `Boolean` | ||
Default: `true` | ||
##### attributes_key | ||
See https://github.com/estheban/node-json2xml#options--behaviour | ||
Type: `Boolean` | ||
Default: 'undefined' | ||
## License | ||
MIT ©[Gilad Peleg](http://giladpeleg.com) |
21234
256
432
+ Addedget-stdin@^3.0.2
+ Addedget-stdin@3.0.2(transitive)
- Removedchalk@^0.5.1
- Removedansi-regex@0.2.1(transitive)
- Removedansi-styles@1.1.0(transitive)
- Removedchalk@0.5.1(transitive)
- Removedhas-ansi@0.1.0(transitive)
- Removedstrip-ansi@0.3.0(transitive)
- Removedsupports-color@0.2.0(transitive)