standard-reporter
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "standard-reporter", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Reporters for feross/standard or uber/standard via unix pipes", | ||
@@ -27,2 +27,4 @@ "main": "standard-reporter.js", | ||
"husky": "^0.7.0", | ||
"run-series": "^1.0.2", | ||
"tape": "^4.0.0", | ||
"uber-standard": "^3.6.0" | ||
@@ -29,0 +31,0 @@ }, |
@@ -18,4 +18,2 @@ #!/usr/bin/env node | ||
var DefaultReporter = StylishReporter; | ||
function CheckStyleReporter() { | ||
@@ -79,3 +77,3 @@ // ==== begin attribution ================================================== | ||
].join('\n') + '\n'; | ||
console.log(checkstyle); | ||
this.push(checkstyle); | ||
callback(); | ||
@@ -87,3 +85,3 @@ } | ||
function StylishReporter() { | ||
function StylishReporter(options) { | ||
var tableOptions = { | ||
@@ -102,3 +100,3 @@ align: ['l', 'r', 'l', 'l', 'l'], | ||
if (isTTY) { | ||
if (options.colors) { | ||
line = chalk.magenta(line); | ||
@@ -120,5 +118,5 @@ column = chalk.blue(column); | ||
var errors = fileErrors.errors.map(formatRow); | ||
var header = isTTY ? chalk.underline.cyan(file) : file; | ||
var header = options.colors ? chalk.underline.cyan(file) : file; | ||
var formattedErrors = table(errors, tableOptions); | ||
console.log(header + '\n' + formattedErrors + '\n'); | ||
this.push(header + '\n' + formattedErrors + '\n'); | ||
callback(); | ||
@@ -139,3 +137,3 @@ } | ||
function flush(callback) { | ||
console.log(JSON.stringify(errors, undefined, 2)); | ||
this.push(JSON.stringify(errors, undefined, 2)); | ||
callback(); | ||
@@ -219,23 +217,59 @@ } | ||
var reporter = argv.json ? JSONReporter : | ||
argv.checkstyle ? CheckStyleReporter : | ||
argv.stylish ? StylishReporter : DefaultReporter; | ||
var reporterMap = { | ||
'json': JSONReporter, | ||
'checkstyle': CheckStyleReporter, | ||
'stylish': StylishReporter | ||
}; | ||
process.stdin | ||
.pipe(byline()) | ||
.pipe(parseErrors()) | ||
.pipe(groupErrorsByFile()) | ||
.pipe(reporter()) | ||
.pipe(process.stdout); | ||
function standardReporter(options) { | ||
options = extend({ | ||
type: 'none', | ||
colors: isTTY, | ||
sink: process.stdout | ||
}, options || {}); | ||
process.on('error', function handleError(err) { | ||
console.error(err); | ||
hasErrors = true; | ||
}); | ||
var inputStream = through2(noopTransform); | ||
var reporter = reporterMap[options.type]; | ||
process.on('exit', function onStandardExit() { | ||
if (hasErrors) { | ||
return process.exit(1); | ||
if (reporter) { | ||
inputStream | ||
.pipe(byline()) | ||
.pipe(parseErrors()) | ||
.pipe(groupErrorsByFile()) | ||
.pipe(reporter(options)) | ||
.pipe(options.sink); | ||
} else { | ||
inputStream.pipe(options.sink); | ||
} | ||
process.exit(0); | ||
}); | ||
function noopTransform(chunk, enc, callback) { | ||
this.push(chunk); | ||
callback(); | ||
} | ||
return inputStream; | ||
} | ||
module.exports = standardReporter; | ||
if (require.main === module) { | ||
var type = argv.json ? 'json' : | ||
argv.checkstyle ? 'checkstyle' : | ||
argv.stylish ? 'stylish' : 'none'; | ||
process.stdin.pipe(standardReporter({ | ||
type: type | ||
})); | ||
process.on('error', function handleError(err) { | ||
console.error(err); | ||
hasErrors = true; | ||
}); | ||
process.on('exit', function onStandardExit() { | ||
if (hasErrors) { | ||
return process.exit(1); | ||
} | ||
process.exit(0); | ||
}); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11968
10
267
4
2