From 0a4d6170ba4cf34100ea468181c6fb273a470a77 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Mon, 29 Dec 2014 18:09:30 -0800 Subject: [PATCH] fix(gulpfile): fix the dartanalyzer task --- tools/build/dartanalyzer.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/build/dartanalyzer.js b/tools/build/dartanalyzer.js index 96a0eda952..89771e1d3b 100644 --- a/tools/build/dartanalyzer.js +++ b/tools/build/dartanalyzer.js @@ -31,7 +31,8 @@ module.exports = function(gulp, plugins, config) { })); function analyze(dirName, done) { - var stream = spawn(config.command, ['--fatal-warnings', tempFile], { + //TODO remove --package-warnings once dartanalyzer handles transitive libraries + var stream = spawn(config.command, ['--fatal-warnings', '--package-warnings', tempFile], { // inherit stdin and stderr, but filter stdout stdio: [process.stdin, 'pipe', process.stderr], cwd: dirName @@ -46,19 +47,27 @@ module.exports = function(gulp, plugins, config) { terminal: false }); var hintCount = 0; + var errorCount = 0; rl.on('line', function(line) { + //TODO remove once dartanalyzer handles transitive libraries + //skip errors in third-party packages + if (line.indexOf(dirName) == -1) { + return; + } if (line.match(/Unused import/)) { return; } if (line.match(/\[hint\]/)) { hintCount++; + } else { + errorCount ++; } console.log(dirName + ':' + line); }); - stream.on('close', function(code) { + stream.on('close', function() { var error; - if (code !== 0) { - error = new Error('Dartanalyzer failed with exit code ' + code); + if (errorCount > 0) { + error = new Error('Dartanalyzer showed errors'); } if (hintCount > 0) { error = new Error('Dartanalyzer showed hints');