* Given a file name and options, run verification and print formatted output. * @param {String} relativeFilePath absolute file location * @param {Object} options for processing * @return {Number} exit code
(relativeFilePath, options)
| 138 | * @return {Number} exit code |
| 139 | */ |
| 140 | function processFile(relativeFilePath, options) { |
| 141 | var input = api.readFile(relativeFilePath), |
| 142 | ruleset = filterRules(options), |
| 143 | result = CSSLint.verify(input, gatherRules(options, ruleset)), |
| 144 | formatter = CSSLint.getFormatter(options.format || "text"), |
| 145 | messages = result.messages || [], |
| 146 | output, |
| 147 | exitCode = 0; |
| 148 | |
| 149 | if (!input) { |
| 150 | if (formatter.readError) { |
| 151 | api.print(formatter.readError(relativeFilePath, "Could not read file data. Is the file empty?")); |
| 152 | } else { |
| 153 | api.print("csslint: Could not read file data in " + relativeFilePath + ". Is the file empty?"); |
| 154 | } |
| 155 | exitCode = 1; |
| 156 | } else { |
| 157 | //var relativeFilePath = getRelativePath(api.getWorkingDirectory(), fullFilePath); |
| 158 | options.fullPath = api.getFullPath(relativeFilePath); |
| 159 | output = formatter.formatResults(result, relativeFilePath, options); |
| 160 | if (output) { |
| 161 | api.print(output); |
| 162 | } |
| 163 | |
| 164 | if (messages.length > 0 && pluckByType(messages, "error").length > 0) { |
| 165 | exitCode = 1; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | return exitCode; |
| 170 | } |
| 171 | |
| 172 | |
| 173 | /** |
no test coverage detected
searching dependent graphs…