Skip to content

Commit ddcb40f

Browse files
authored
Merge pull request #267 from underctrl-io/fix-transform
fix: plugin transform issues
2 parents 28badf0 + 3df19d5 commit ddcb40f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/commandkit/src/plugins/plugin-runtime/CompilerPluginRuntime.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
isCompilerPlugin,
77
} from '..';
88
import { AsyncLocalStorage } from 'node:async_hooks';
9+
import { Logger } from '../../logger/Logger';
910

1011
/**
1112
* Interface representing a template entry in the plugin runtime.
@@ -91,7 +92,7 @@ export class CompilerPluginRuntime {
9192
}
9293

9394
/**
94-
* Unregisters a template handler for a given name.
95+
* Unregister a template handler for a given name.
9596
* This method must be called inside the deactivate() method of a plugin.
9697
* @param name - The name of the template to unregister.
9798
*/
@@ -153,6 +154,13 @@ export class CompilerPluginRuntime {
153154
): Promise<{ code: string; map: string | null }> {
154155
let map: string | null = null;
155156
for (const plugin of this.plugins) {
157+
if (!plugin?.transform || typeof plugin?.transform !== 'function') {
158+
Logger.warn(
159+
`Plugin ${plugin?.name ?? '<unknown>'} is invalid or does not have a transform method or the method is not a function`,
160+
);
161+
continue;
162+
}
163+
156164
try {
157165
const res: MaybeFalsey<TransformedResult> = await plugin.transform?.({
158166
code,

0 commit comments

Comments
 (0)