Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cli/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function cli(api) {
var globalOptions = {
"help" : { "format" : "", "description" : "Displays this information." },
"format" : { "format" : "<format>", "description" : "Indicate which format to use for output." },
"formatter" : { "format" : "<formatter>", "description" : "Path to a formatter to load. Only supported in Node.js" },
"list-rules" : { "format" : "", "description" : "Outputs all of the rules available." },
"quiet" : { "format" : "", "description" : "Only output when errors are present." },
"errors" : { "format" : "<rule[,rule]+>", "description" : "Indicate which rules to include as errors." },
Expand Down Expand Up @@ -223,6 +224,17 @@ function cli(api) {
api.print("csslint: No files specified.");
exitCode = 1;
} else {
if (api.isNode && options.formatter) {
/*jshint node:true */
var path = require("path");
var fullPath = path.resolve(process.cwd(), options.formatter);

var customFormatter = require(fullPath);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line could throw exception. Catch it and return exitcode = 1?


CSSLint.addFormatter(customFormatter);
/*jshint node:false */
}

if (!CSSLint.hasFormat(formatId)) {
api.print("csslint: Unknown format '" + formatId + "'. Cannot proceed.");
exitCode = 1;
Expand Down
4 changes: 3 additions & 1 deletion src/cli/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ cli({
} catch (ex) {
return "";
}
}
},

isNode: true
});