Skip to content

Commit

Permalink
fix(preprocessor): do not show duplicate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Jun 28, 2013
1 parent c645c06 commit 47c641f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ var sha1 = function(data) {
return hash.digest('hex');
};


// TODO(vojta): instantiate preprocessors at the start to show warnings immediately
var createPreprocessor = function(config, basePath, injector) {
var patterns = Object.keys(config);
var alreadyDisplayedWarnings = Object.create(null);

return function(file, done) {
var preprocessors = [];
Expand All @@ -27,16 +28,21 @@ var createPreprocessor = function(config, basePath, injector) {
preprocessors.shift()(content, file, nextPreprocessor);
};
var instantiatePreprocessor = function(name) {
if (alreadyDisplayedWarnings[name]) {
return;
}

try {
preprocessors.push(injector.get('preprocessor:' + name));
} catch (e) {
// TODO(vojta): log warning only once per each preprocessor
if (e.message.indexOf('No provider for "preprocessor:' + name + '"') !== -1) {
log.warn('Can not load "%s", it is not registered!\n ' +
'Perhaps you are missing some plugin?', name);
} else {
log.warn('Can not load "%s"!\n ' + e.stack, name);
}

alreadyDisplayedWarnings[name] = true;
}
};

Expand Down

0 comments on commit 47c641f

Please sign in to comment.