-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hays Clark
committed
Sep 27, 2015
1 parent
bf70cb3
commit 0fb7c96
Showing
26 changed files
with
1,107 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
.idea | ||
node_modules/ | ||
woodchipper-*.tgz | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.idea | ||
.git | ||
.gitignore | ||
.travis.yml | ||
node_modules | ||
spec | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "0.12" | ||
|
||
after_success: | ||
- ./node_modules/.bin/istanbul cover -x '**/spec/**' ./node_modules/mocha/bin/_mocha --report lcovonly -- --recursive --require spec/helpers/chai.js spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2015 Hays Clark | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,32 @@ | ||
# scrutiny | ||
Woodchipper [![Build Status](https://travis-ci.org/haysclark/woodchipper.svg)](https://travis-ci.org/haysclark/woodchipper)[![Coverage Status](https://coveralls.io/repos/haysclark/woodchipper/badge.svg?branch=develop&service=github)](https://coveralls.io/github/haysclark/woodchipper?branch=develop) | ||
=========== | ||
|
||
A simple module and CLI utility that converts [Treeherder](https://wiki.mozilla.org/Auto-tools/Projects/Treeherder) (the successor to [TBPL](https://wiki.mozilla.org/Sheriffing/TBPL)) output to [JUnit](http://junit.org/) xml. | ||
|
||
## Installation | ||
|
||
npm install woodchipper -g | ||
|
||
## Usage | ||
|
||
woodchipper [--version] [--help] [--format=<name>] <input> | ||
|
||
## Tests | ||
|
||
npm test | ||
npm run coverage | ||
|
||
## Development | ||
|
||
npm install | ||
npm link | ||
woodchipper | ||
|
||
## Contributing | ||
|
||
In lieu of a formal styleguide, take care to maintain the existing coding style. | ||
Add unit tests for any new or changed functionality. Lint and test your code. | ||
|
||
## Release History | ||
|
||
* 0.8.9 alpha release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env node | ||
|
||
var cli = require('../lib/cli'), | ||
argv = require('minimist')(process.argv.slice(2)); | ||
|
||
/** | ||
* treating the CLI as a module for better test coverage. | ||
*/ | ||
cli.argv(argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Name: | ||
|
||
woodchipper - chops up trees | ||
|
||
Description: | ||
|
||
Simple Treeherder converter. | ||
|
||
Usage: | ||
|
||
woodchipper [--version] [--help] [--format=<name>] <input> | ||
|
||
Options: | ||
|
||
-v, --version output version number | ||
-h, --help output usage information | ||
-f, --format output format (default format is junit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
usage: woodchipper [--version] [--help] [--format=<name>] <input> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var argv = require('./argv'), | ||
help = require('./help'), | ||
version = require('./version'), | ||
parse = require('./parse'); | ||
|
||
/** | ||
* routes argv settings to cli modules | ||
* | ||
* @param argv | ||
*/ | ||
module.exports = function(argv) { | ||
// --help or -h | ||
argv.help = argv.help || argv.h; | ||
if(argv.help) { | ||
help(null, onComplete); | ||
return; | ||
} | ||
|
||
// --version or -v | ||
argv.version = argv.version || argv.v; | ||
if(argv.version) { | ||
version(argv, onComplete); | ||
} | ||
|
||
// default parse action | ||
parse(argv, onComplete); | ||
}; | ||
|
||
function onComplete(err, data) { | ||
if(err) { | ||
console.error(err); | ||
help('usage', logger); | ||
process.exit(1); | ||
} | ||
logger(null, data); | ||
}; | ||
|
||
function logger(err, data) { | ||
console.log(data + '\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var path = require('path'), | ||
fs = require('fs'); | ||
|
||
/** | ||
* returns help information for topc | ||
* | ||
* @param topic | ||
* @param callback | ||
*/ | ||
module.exports = function(topic, callback) { | ||
if(topic == null) { | ||
topic = 'about'; | ||
} | ||
findHelpTopic(topic, callback); | ||
}; | ||
|
||
function findHelpTopic(topic, callback) { | ||
// filename format: help.topic.txt | ||
var filepath = [topic]; | ||
filepath.push('txt'); | ||
filepath = filepath.join('.'); | ||
|
||
// full doc file path | ||
var basepath = path.join(__dirname, '..', '..', 'doc', 'cli'); | ||
filepath = path.join(basepath, filepath); | ||
|
||
// get help info | ||
var data = fs.readFileSync(filepath, 'utf8'); | ||
callback(null, data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Command line commands. | ||
*/ | ||
module.exports = { | ||
argv: require('./argv'), | ||
help: require('./help'), | ||
version: require('./version'), | ||
parse: require('./parse') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var woodchipper = require('../woodchipper'); | ||
|
||
var TIMEOUT = 100; | ||
|
||
/** | ||
* routes argv or stdin input and format to parser | ||
* | ||
* @param argv | ||
* @param callback | ||
*/ | ||
module.exports = function(argv, callback) { | ||
// handle command arguments and piped data via stdin | ||
if(validateArgs(argv)) { | ||
routeToParse(argv._[0], argv, callback); | ||
} else if(argv._.length <= 1) { | ||
handleStdin(TIMEOUT, function (err, data) { | ||
if(err) { | ||
callback('too few arguments'); | ||
} | ||
routeToParse(data, argv, callback); | ||
}); | ||
} else { | ||
callback('too many arguments'); | ||
} | ||
}; | ||
|
||
function validateArgs(argv) { | ||
return (argv._.length == 1); | ||
} | ||
|
||
function handleStdin(dur, callback) { | ||
var stdin = process.openStdin(); | ||
var timeout = setTimeout(function() { | ||
if(data) { | ||
// data incoming, waiting for stdin end | ||
return; | ||
} else { | ||
callback('timed out after ' + dur); | ||
} | ||
}, dur); | ||
|
||
var data; | ||
stdin.on('data', function(chunk) { | ||
data = (!!data) ? data : ''; | ||
data += chunk; | ||
}); | ||
stdin.on('end', function() { | ||
clearTimeout(timeout); | ||
callback(null, data); | ||
}); | ||
} | ||
|
||
function routeToParse(data, argv, callback) { | ||
// --format or -f | ||
argv.format = argv.format || argv.f; | ||
woodchipper.parse(data, argv.format, callback); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var pjson = require('../../package.json'); | ||
|
||
/** | ||
* outputs the version number | ||
* | ||
* @param argv | ||
* @param callback | ||
*/ | ||
module.exports = function(argv, callback) { | ||
callback(null, pjson.version); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
parse: require('./parse') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var DEFAULT_PARSER = 'junit'; | ||
|
||
/** | ||
* Routes to data to parser. | ||
* | ||
* @param data | ||
* @param callback | ||
*/ | ||
module.exports = function(data, format, callback) { | ||
if(format == null) { | ||
format = DEFAULT_PARSER; | ||
} | ||
|
||
findParser(format, data, callback); | ||
}; | ||
|
||
function findParser(format, data, callback) { | ||
// parser module format: ./parser/format.js | ||
var module = './parser/' + format; | ||
try { | ||
var parser = require(module); | ||
parser(data, callback); | ||
} catch(err) { | ||
callback('unknown format: ' + format); | ||
} | ||
} |
Oops, something went wrong.