Commit bc61a6be authored by David Sveningsson's avatar David Sveningsson

fix(config): throw error is plugin is missing

parent e1844c08
......@@ -475,6 +475,17 @@ describe("config", () => {
);
});
it("should throw error if transformer refers to missing plugin", () => {
const config = Config.fromObject({
transform: {
"^.*\\.foo$": "missing-plugin:foo",
},
});
expect(() => config.init()).toThrow(
'Failed to load transformer "missing-plugin:foo": No plugin named "missing-plugin" has been loaded'
);
});
it("should return original source if no transformer is found", () => {
const config = Config.fromObject({
transform: {
......
......@@ -472,6 +472,11 @@ export class Config {
if (match) {
const [, pluginName, key] = match;
const plugin = this.plugins.find(cur => cur.name === pluginName);
if (!plugin) {
throw new ConfigError(
`No plugin named "${pluginName}" has been loaded`
);
}
if (!plugin.transformer) {
throw new ConfigError(`Plugin does not expose any transformer`);
}
......
......@@ -382,6 +382,19 @@ describe("Plugin", () => {
`);
});
it("should throw error when named transform is missing plugin", () => {
expect.assertions(1);
mockPlugin.transformer = {};
config = Config.fromObject({
transform: {
".*": "missing-plugin:foobar",
},
});
expect(() => config.init()).toThrow(
'Failed to load transformer "missing-plugin:foobar": No plugin named "missing-plugin" has been loaded'
);
});
it("should throw error when named transform is missing", () => {
expect.assertions(1);
mockPlugin.transformer = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment