From 7c75951380fd7ab19461dd3292d0ea9d89c44e75 Mon Sep 17 00:00:00 2001 From: Lucian Buzzo Date: Fri, 22 Dec 2017 10:04:01 +0000 Subject: [PATCH] further improvements --- lib/resin-lint.coffee | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/resin-lint.coffee b/lib/resin-lint.coffee index afbb796..1f67071 100644 --- a/lib/resin-lint.coffee +++ b/lib/resin-lint.coffee @@ -69,7 +69,14 @@ lintCoffeeFiles = (files, config) -> for file in files source = read(file) errorReport.lint(file, source, config) - return errorReport + errorReport + + report = new reporter errorReport, + colorize: process.stdout.isTTY + quiet: false + report.publish() + + return errorReport.getExitCode() lintTsFiles = (files, config) -> parsedConfig = tslint.Configuration.parseConfigFile(config) @@ -80,35 +87,24 @@ lintTsFiles = (files, config) -> for file in files source = read(file) linter.lint(file, source, parsedConfig) - return linter.getResult() -runLint = (resinLintConfig, paths, config) -> - scripts = findFiles(resinLintConfig.extensions, paths) + errorReport = linter.getResult() - if resinLintConfig.lang is 'typescript' - errorReport = lintTsFiles(scripts, config) + console.log(linter.getResult().output) - console.log(errorReport.output) + return if errorReport.errorCount is 0 then 0 else 1 - process.on 'exit', -> - process.exit(errorReport.errorCount > 0 : 1 : 0) +runLint = (resinLintConfig, paths, config) -> + scripts = findFiles(resinLintConfig.extensions, paths) - return + if resinLintConfig.lang is 'typescript' + linterExitCode = lintTsFiles(scripts, config) if resinLintConfig.lang is 'coffeescript' - errorReport = lintCoffeeFiles(scripts, config) - - report = new reporter errorReport, - colorize: process.stdout.isTTY - quiet: false - report.publish() - - process.on 'exit', -> - process.exit(errorReport.getExitCode()) - - return + linterExitCode = lintCoffeeFiles(scripts, config) - throw new Error("Language #{resinlintConfig.language} is not supported by resin-lint.") + process.on 'exit', -> + process.exit(linterExitCode) module.exports = (passed_params) -> try