Skip to content

Commit 9eaeef3

Browse files
committed
🐛 Fix CLI output
1 parent 1c6197b commit 9eaeef3

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

bin/sass-lint.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@ var tooManyWarnings = function (detects, userConfig) {
1616
return warningCount > 0 && warningCount > userConfig.options['max-warnings'];
1717
};
1818

19-
var detectPattern = function (pattern, userConfig) {
19+
var detectPattern = function (pattern) {
2020
var detects = lint.lintFiles(pattern, configOptions, configPath);
2121

22-
if (program.verbose) {
23-
lint.outputResults(detects, configOptions, configPath);
24-
}
25-
26-
if (lint.errorCount(detects).count || tooManyWarnings(detects, userConfig)) {
27-
exitCode = 1;
28-
}
29-
3022
if (program.exit) {
3123
lint.failOnError(detects, configOptions, configPath);
3224
}
25+
return detects;
3326
};
3427

3528
program
@@ -72,17 +65,28 @@ if (program.maxWarnings && program.maxWarnings !== true) {
7265
configOptions.options['max-warnings'] = program.maxWarnings;
7366
}
7467

75-
// load our config here so we only load it once for each file
76-
config = lint.getConfig(configOptions, configPath);
68+
(function () {
69+
// load our config here so we only load it once for each file
70+
config = lint.getConfig(configOptions, configPath);
71+
var results = [];
7772

78-
if (program.args.length === 0) {
79-
detectPattern(null, config);
80-
}
81-
else {
82-
program.args.forEach(function (path) {
83-
detectPattern(path, config);
84-
});
85-
}
73+
if (program.args.length === 0) {
74+
results = results.concat(detectPattern(null));
75+
}
76+
else {
77+
program.args.forEach(function (path) {
78+
results = results.concat(detectPattern(path));
79+
});
80+
}
81+
82+
if (program.verbose) {
83+
lint.outputResults(results, configOptions, configPath);
84+
}
85+
86+
if (lint.errorCount(results).count || tooManyWarnings(results, config)) {
87+
exitCode = 1;
88+
}
89+
}());
8690

8791
process.on('exit', function () {
8892
process.exit(exitCode); // eslint-disable-line no-process-exit

0 commit comments

Comments
 (0)