refactor(plugin-workflow): change files mode to 644 (#755)

This commit is contained in:
Junyi 2022-08-19 10:00:20 +08:00 committed by GitHub
parent 2a18967418
commit 58b4febdf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 8 deletions

0
packages/plugins/workflow/client.d.ts vendored Executable file → Normal file
View File

0
packages/plugins/workflow/client.js Executable file → Normal file
View File

0
packages/plugins/workflow/server.d.ts vendored Executable file → Normal file
View File

0
packages/plugins/workflow/server.js Executable file → Normal file
View File

View File

@ -36,9 +36,11 @@ export interface Instruction {
): InstructionResult ): InstructionResult
} }
type InstructionConstructor<T> = { new(p: Plugin): T };
export default function<T extends Instruction>( export default function<T extends Instruction>(
plugin, plugin,
more: { [key: string]: T | { new(p: Plugin): T } } = {} more: { [key: string]: T | InstructionConstructor<T> } = {}
) { ) {
const { instructions } = plugin; const { instructions } = plugin;
@ -52,13 +54,14 @@ export default function<T extends Instruction>(
'create', 'create',
'update', 'update',
'destroy' '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 })) { for (const [name, instruction] of Object.entries({ ...more, ...natives })) {
const instruction = typeof value === 'string' instructions.register(name, typeof instruction === 'function'
? requireModule(path.isAbsolute(value) ? value : path.join(__dirname, value)) ? new (instruction as InstructionConstructor<T>)(plugin)
: value; : instruction
);
instructions.register(name, typeof instruction === 'function' ? new instruction(plugin) : instruction);
} }
} }