diff --git a/packages/plugins/workflow/client.d.ts b/packages/plugins/workflow/client.d.ts old mode 100755 new mode 100644 diff --git a/packages/plugins/workflow/client.js b/packages/plugins/workflow/client.js old mode 100755 new mode 100644 diff --git a/packages/plugins/workflow/server.d.ts b/packages/plugins/workflow/server.d.ts old mode 100755 new mode 100644 diff --git a/packages/plugins/workflow/server.js b/packages/plugins/workflow/server.js old mode 100755 new mode 100644 diff --git a/packages/plugins/workflow/src/server/instructions/index.ts b/packages/plugins/workflow/src/server/instructions/index.ts index 5c50e2d1e..c1cfe8fbd 100644 --- a/packages/plugins/workflow/src/server/instructions/index.ts +++ b/packages/plugins/workflow/src/server/instructions/index.ts @@ -36,9 +36,11 @@ export interface Instruction { ): InstructionResult } +type InstructionConstructor = { new(p: Plugin): T }; + export default function( plugin, - more: { [key: string]: T | { new(p: Plugin): T } } = {} + more: { [key: string]: T | InstructionConstructor } = {} ) { const { instructions } = plugin; @@ -52,13 +54,14 @@ export default function( 'create', 'update', 'destroy' - ].reduce((result, key) => Object.assign(result, { [key]: key }), {}); + ].reduce((result, key) => Object.assign(result, { + [key]: requireModule(path.isAbsolute(key) ? key : path.join(__dirname, key)) + }), {}); - for (const [name, value] of Object.entries({ ...more, ...natives })) { - const instruction = typeof value === 'string' - ? requireModule(path.isAbsolute(value) ? value : path.join(__dirname, value)) - : value; - - instructions.register(name, typeof instruction === 'function' ? new instruction(plugin) : instruction); + for (const [name, instruction] of Object.entries({ ...more, ...natives })) { + instructions.register(name, typeof instruction === 'function' + ? new (instruction as InstructionConstructor)(plugin) + : instruction + ); } }