1 | import { Kernel } from '@tarojs/service'
|
2 |
|
3 | export default function customCommand (
|
4 | command: string,
|
5 | kernel: Kernel,
|
6 | args: { _: string[], [key: string]: any }
|
7 | ) {
|
8 | if (typeof command === 'string') {
|
9 | const options: any = {}
|
10 | const excludeKeys = ['_', 'version', 'v', 'help', 'h']
|
11 | Object.keys(args).forEach(key => {
|
12 | if (!excludeKeys.includes(key)) {
|
13 | options[key] = args[key]
|
14 | }
|
15 | })
|
16 | kernel.run({
|
17 | name: command,
|
18 | opts: {
|
19 | _: args._,
|
20 | options,
|
21 | isHelp: args.h
|
22 | }
|
23 | })
|
24 | }
|
25 | }
|