Skip to content

Commit

Permalink
fix(preprocessor): Improve handling of failed preprocessors
Browse files Browse the repository at this point in the history
Closes #1521
  • Loading branch information
dignifiedquire committed Jan 4, 2016
1 parent 6de4610 commit e726d1c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/preprocessor.js
Expand Up @@ -27,8 +27,10 @@ var createPreprocessor = function (config, basePath, injector) {
return
}

var p

try {
instances[name] = injector.get('preprocessor:' + name)
p = injector.get('preprocessor:' + name)
} catch (e) {
if (e.message.indexOf('No provider for "preprocessor:' + name + '"') !== -1) {
log.warn('Can not load "%s", it is not registered!\n ' +
Expand All @@ -39,6 +41,8 @@ var createPreprocessor = function (config, basePath, injector) {

alreadyDisplayedWarnings[name] = true
}

return p
}

patterns.forEach(function (pattern) {
Expand Down Expand Up @@ -80,10 +84,21 @@ var createPreprocessor = function (config, basePath, injector) {
config[patterns[i]].join(', '), file.originalPath)
} else {
config[patterns[i]].forEach(function (name) {
if (!instances[name]) {
instantiatePreprocessor(name)
var p = instances[name]
if (p == null) {
p = instantiatePreprocessor(name)
}
preprocessors.push(instances[name])

if (p == null) {
if (!alreadyDisplayedWarnings[name]) {
alreadyDisplayedWarnings[name] = true
log.warn('Failed to instantiate preprocessor %s', name)
}
return
}

instances[name] = p
preprocessors.push(p)
})
}
}
Expand Down

0 comments on commit e726d1c

Please sign in to comment.