Skip to content

Commit 0a4d617

Browse files
committed
fix(gulpfile): fix the dartanalyzer task
1 parent 3a80c41 commit 0a4d617

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tools/build/dartanalyzer.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module.exports = function(gulp, plugins, config) {
3131
}));
3232

3333
function analyze(dirName, done) {
34-
var stream = spawn(config.command, ['--fatal-warnings', tempFile], {
34+
//TODO remove --package-warnings once dartanalyzer handles transitive libraries
35+
var stream = spawn(config.command, ['--fatal-warnings', '--package-warnings', tempFile], {
3536
// inherit stdin and stderr, but filter stdout
3637
stdio: [process.stdin, 'pipe', process.stderr],
3738
cwd: dirName
@@ -46,19 +47,27 @@ module.exports = function(gulp, plugins, config) {
4647
terminal: false
4748
});
4849
var hintCount = 0;
50+
var errorCount = 0;
4951
rl.on('line', function(line) {
52+
//TODO remove once dartanalyzer handles transitive libraries
53+
//skip errors in third-party packages
54+
if (line.indexOf(dirName) == -1) {
55+
return;
56+
}
5057
if (line.match(/Unused import/)) {
5158
return;
5259
}
5360
if (line.match(/\[hint\]/)) {
5461
hintCount++;
62+
} else {
63+
errorCount ++;
5564
}
5665
console.log(dirName + ':' + line);
5766
});
58-
stream.on('close', function(code) {
67+
stream.on('close', function() {
5968
var error;
60-
if (code !== 0) {
61-
error = new Error('Dartanalyzer failed with exit code ' + code);
69+
if (errorCount > 0) {
70+
error = new Error('Dartanalyzer showed errors');
6271
}
6372
if (hintCount > 0) {
6473
error = new Error('Dartanalyzer showed hints');

0 commit comments

Comments
 (0)