fix(gulpfile): fix the dartanalyzer task
This commit is contained in:
parent
3a80c4197d
commit
0a4d6170ba
|
@ -31,7 +31,8 @@ module.exports = function(gulp, plugins, config) {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function analyze(dirName, done) {
|
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
|
// inherit stdin and stderr, but filter stdout
|
||||||
stdio: [process.stdin, 'pipe', process.stderr],
|
stdio: [process.stdin, 'pipe', process.stderr],
|
||||||
cwd: dirName
|
cwd: dirName
|
||||||
|
@ -46,19 +47,27 @@ module.exports = function(gulp, plugins, config) {
|
||||||
terminal: false
|
terminal: false
|
||||||
});
|
});
|
||||||
var hintCount = 0;
|
var hintCount = 0;
|
||||||
|
var errorCount = 0;
|
||||||
rl.on('line', function(line) {
|
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/)) {
|
if (line.match(/Unused import/)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (line.match(/\[hint\]/)) {
|
if (line.match(/\[hint\]/)) {
|
||||||
hintCount++;
|
hintCount++;
|
||||||
|
} else {
|
||||||
|
errorCount ++;
|
||||||
}
|
}
|
||||||
console.log(dirName + ':' + line);
|
console.log(dirName + ':' + line);
|
||||||
});
|
});
|
||||||
stream.on('close', function(code) {
|
stream.on('close', function() {
|
||||||
var error;
|
var error;
|
||||||
if (code !== 0) {
|
if (errorCount > 0) {
|
||||||
error = new Error('Dartanalyzer failed with exit code ' + code);
|
error = new Error('Dartanalyzer showed errors');
|
||||||
}
|
}
|
||||||
if (hintCount > 0) {
|
if (hintCount > 0) {
|
||||||
error = new Error('Dartanalyzer showed hints');
|
error = new Error('Dartanalyzer showed hints');
|
||||||
|
|
Loading…
Reference in New Issue