mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 12:41:54 +03:00
fec189f2f3
bundler: - Prevent stack overflow. (denoland/deno#9752) testing: - Bump version - Fix handling of paths on windows. testing_macros: - Bump version - Correctly ignore files.
22 lines
530 B
TypeScript
22 lines
530 B
TypeScript
// Loaded from https://deno.land/x/cliffy@v0.18.0/flags/types/boolean.ts
|
|
|
|
|
|
import type { ITypeHandler, ITypeInfo } from "../types.ts";
|
|
|
|
/** Boolean type handler. Excepts `true`, `false`, `1`, `0` */
|
|
export const boolean: ITypeHandler<boolean> = (
|
|
{ label, name, value, type }: ITypeInfo,
|
|
): boolean => {
|
|
if (~["1", "true"].indexOf(value)) {
|
|
return true;
|
|
}
|
|
|
|
if (~["0", "false"].indexOf(value)) {
|
|
return false;
|
|
}
|
|
|
|
throw new Error(
|
|
`${label} "${name}" must be of type "${type}", but got "${value}".`,
|
|
);
|
|
};
|