mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 01:37:24 +00:00
76f911041a
* use named exports * fix test * add missing imnport * fix prettier
17 lines
450 B
TypeScript
17 lines
450 B
TypeScript
import { isBoolean } from '@sindresorhus/is';
|
|
|
|
const stringMapping: ReadonlyMap<string, boolean> = new Map<string, boolean>([
|
|
['True', true],
|
|
['False', false],
|
|
]);
|
|
|
|
export const booleanStringValues = Array.from(stringMapping.keys());
|
|
|
|
export function asBoolean(value: string): boolean {
|
|
const result = stringMapping.get(value);
|
|
if (isBoolean(result)) {
|
|
return result;
|
|
}
|
|
throw new Error(`Invalid Starlark boolean string: ${value}`);
|
|
}
|