From 58b4febdf8a95aeaac68962240f734e2c394e2a9 Mon Sep 17 00:00:00 2001 From: Junyi Date: Fri, 19 Aug 2022 10:00:20 +0800 Subject: [PATCH] refactor(plugin-workflow): change files mode to 644 (#755) --- packages/plugins/workflow/client.d.ts | 0 packages/plugins/workflow/client.js | 0 packages/plugins/workflow/server.d.ts | 0 packages/plugins/workflow/server.js | 0 .../workflow/src/server/instructions/index.ts | 19 +++++++++++-------- 5 files changed, 11 insertions(+), 8 deletions(-) mode change 100755 => 100644 packages/plugins/workflow/client.d.ts mode change 100755 => 100644 packages/plugins/workflow/client.js mode change 100755 => 100644 packages/plugins/workflow/server.d.ts mode change 100755 => 100644 packages/plugins/workflow/server.js 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 5c50e2d1e1..c1cfe8fbd2 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 + ); } }