Skip to content

Commit

Permalink
fix(preprocessor): Improve handling of failed preprocessors
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jan 4, 2016
1 parent a731968 commit d05733b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/preprocessor.js
Original file line number Diff line number Diff line change
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 d05733b

Please sign in to comment.