Skip to content

Commit 12b2d48

Browse files
committed
Call onTransformEnd even if plugin does not implement transform
1 parent 6ff2a39 commit 12b2d48

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/sourcebit.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ class Sourcebit {
195195
const plugin = this.pluginModules[index];
196196
const pluginName = this.getNameOfPluginAtIndex(index);
197197

198-
if (typeof plugin.transform !== 'function') {
199-
return data;
200-
}
201-
202198
if (typeof plugin.onTransformEnd === 'function') {
203199
onTransformEndCallbacks.push({
204200
args: {
@@ -211,6 +207,10 @@ class Sourcebit {
211207
});
212208
}
213209

210+
if (typeof plugin.transform !== 'function') {
211+
return data;
212+
}
213+
214214
return plugin.transform({
215215
data,
216216
debug: this.getDebugMethodForPlugin(pluginName),

lib/sourcebit.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ describe('`transform()`', () => {
938938
};
939939
}
940940
}
941+
},
942+
{
943+
module: {
944+
name: 'sourcebit-test4',
945+
onTransformEnd: onTransformEndFn
946+
}
941947
}
942948
];
943949
const callback = jest.fn();
@@ -950,7 +956,7 @@ describe('`transform()`', () => {
950956

951957
const data = await sourcebit.transform();
952958

953-
expect(onTransformEndFn).toHaveBeenCalledTimes(3);
959+
expect(onTransformEndFn).toHaveBeenCalledTimes(4);
954960

955961
onTransformEndFn.mock.calls.forEach(call => {
956962
expect(call[0].debug).toBeInstanceOf(Function);

0 commit comments

Comments
 (0)