Skip to content

Commit fd4ccd9

Browse files
committed
feat(plugins): Allow plugins to be given inline within options hash
1 parent 87a2381 commit fd4ccd9

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

lib/async.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ module.exports = {
266266
try {
267267
bs.registerPlugin(require(name), opts);
268268
} catch (e) {
269-
bs.logger.error("NOPE");
269+
bs.logger.setOnce("useLevelPrefixes", true).error("Plugin {yellow:`%s`} was not found, did you forget to {cyan:npm install} it?", name);
270270
}
271271
}
272272

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 with errors", function () {
8+
9+
var instance;
10+
11+
before(function (done) {
12+
13+
browserSync.reset();
14+
15+
var config = {
16+
logLevel: "error",
17+
plugins: ["some-rnadomw-name-that-does-not-exist"]
18+
};
19+
20+
instance = browserSync(config, done).instance;
21+
});
22+
after(function () {
23+
instance.cleanup();
24+
});
25+
it("Should give good errors when a plugin does not exist", function (done) {
26+
assert.equal(instance.getUserPlugins().length, 0);
27+
done();
28+
});
29+
});

test/specs/plugins/user.plugins.inline.options.js

-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ describe("Plugins: Retrieving user plugins when given inline with options", func
1313

1414
browserSync.reset();
1515

16-
var plugin = {
17-
"bs-html-injector": {
18-
files: "*.html"
19-
}
20-
};
21-
2216
var config = {
2317
logLevel: "silent",
2418
plugins: [

0 commit comments

Comments
 (0)