UNPKG

551 BPlain TextView Raw
1import { Kernel } from '@tarojs/service'
2
3export 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
17 kernel.run({
18 name: command,
19 opts: {
20 _: args._,
21 options,
22 isHelp: args.h
23 }
24 })
25 }
26}