Skip to content

Commit 99c0253

Browse files
authored
fix(registerplugin): better error on type (#225)
* fix(registerplugin): better error on type When given the wrong type for a plugin, throw a proper explaination. closes #219 * fix(typo): fix typo in errormessage
1 parent 6ee2b01 commit 99c0253

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

scully/pluginManagement/pluginRepository.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ export const registerPlugin = (
3939
{replaceExistingPlugin = false} = {}
4040
) => {
4141
if (!['router', 'render', 'fileHandler'].includes(type)) {
42-
throw new Error(
43-
`Type "${yellow(type)}" is not a known plugin type for registering plugin "${yellow(name)}"`
44-
);
42+
throw new Error(`
43+
--------------
44+
Type "${yellow(type)}" is not a known plugin type for registering plugin "${yellow(name)}".
45+
The first parameter of registerPlugin needs to be one of: 'fileHandler', 'router', 'render'
46+
--------------
47+
`);
4548
}
4649
if (replaceExistingPlugin === false && plugins[type][name]) {
4750
throw new Error(`Plugin ${name} already exists`);

scully/pluginManagement/systemPlugins.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ import '../fileHanderPlugins/asciidoc';
33
import '../renderPlugins/contentRenderPlugin';
44
import '../routerPlugins/jsonRoutePlugin';
55
import '../routerPlugins/contentFolderPlugin';
6+
import '../routerPlugins/ignoredRoutePlugin';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerPlugin} from '../pluginManagement/pluginRepository';
2+
3+
/**
4+
* The ignoredPlugin helps to take routes out.
5+
* when you use this plugin, the route will never be rendered.
6+
*/
7+
registerPlugin('router', 'ignored', () => []);

0 commit comments

Comments
 (0)