Skip to content

Commit 8113649

Browse files
committed
[wip] - adding support for plugin errors
1 parent f0ac65f commit 8113649

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

lib/async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module.exports = {
126126
});
127127

128128
function logPluginError (plugin) {
129-
utils.fail(true, new Error("Plugin: " + plugin.get("name") + " not found"), bs.cb);
129+
utils.fail(true, plugin.getIn(["errors", 0]), bs.cb);
130130
}
131131

132132
done();

lib/plugins.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var Immutable = require("immutable");
22
var Map = Immutable.Map;
3+
var isMap = Immutable.Map.isMap;
34
var List = Immutable.List;
45
var qs = require("qs");
56
var path = require("path");
@@ -32,6 +33,10 @@ function resolvePlugin(item) {
3233
return getFromString(item);
3334
}
3435

36+
if (!isMap(item)) {
37+
return new Plugin().mergeDeep({errors: [new Error("Plugin not supported in this format")]});
38+
}
39+
3540
if (item.has("module")) {
3641

3742
var nameOrObj = item.get("module");
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use strict";
2+
3+
var browserSync = require("../../../");
4+
5+
var assert = require("chai").assert;
6+
7+
describe("Plugins: Retrieving user plugins when given inline, but with error", function () {
8+
it.only("Should fail if a plugin error occurred", function (done) {
9+
browserSync.reset();
10+
11+
browserSync({
12+
plugins: {
13+
module: {plugin: function () {
14+
15+
}}
16+
},
17+
open: false,
18+
logLevel: "silent"
19+
}, function (err, bs) {
20+
console.log(err);
21+
done();
22+
});
23+
});
24+
});

0 commit comments

Comments
 (0)