Skip to content

Commit e726d1c

Browse files
fix(preprocessor): Improve handling of failed preprocessors
Closes #1521
1 parent 6de4610 commit e726d1c

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

lib/preprocessor.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ var createPreprocessor = function (config, basePath, injector) {
2727
return
2828
}
2929

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

4042
alreadyDisplayedWarnings[name] = true
4143
}
44+
45+
return p
4246
}
4347

4448
patterns.forEach(function (pattern) {
@@ -80,10 +84,21 @@ var createPreprocessor = function (config, basePath, injector) {
8084
config[patterns[i]].join(', '), file.originalPath)
8185
} else {
8286
config[patterns[i]].forEach(function (name) {
83-
if (!instances[name]) {
84-
instantiatePreprocessor(name)
87+
var p = instances[name]
88+
if (p == null) {
89+
p = instantiatePreprocessor(name)
8590
}
86-
preprocessors.push(instances[name])
91+
92+
if (p == null) {
93+
if (!alreadyDisplayedWarnings[name]) {
94+
alreadyDisplayedWarnings[name] = true
95+
log.warn('Failed to instantiate preprocessor %s', name)
96+
}
97+
return
98+
}
99+
100+
instances[name] = p
101+
preprocessors.push(p)
87102
})
88103
}
89104
}

0 commit comments

Comments
 (0)