commands: create a dedicated commands directory
This commit is contained in:
10
commands/common.ts
Normal file
10
commands/common.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export function undefList<T, U>(opt: T | undefined, fn: (opt: T) => U) {
|
||||
return opt === undefined ? [] : fn(opt)
|
||||
}
|
||||
|
||||
export const optFlag = (flag: string, opt: string | undefined) => undefList(opt, opt => [flag, opt])
|
||||
|
||||
/**
|
||||
* Generate a switch flag, like "--rebuild", "--nobuild"
|
||||
*/
|
||||
export const optSwitch = (flag: string, opt: boolean | undefined) => undefList(opt, opt => opt ? [flag] : [])
|
||||
Reference in New Issue
Block a user