Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function withStyle({ children, style }: any): string {
const flattenStyle = StyleSheetflattenStyle(style) || {};
const textAlign = flattenStyle.textAlign || 'left';
const alignSelf = flattenStyle.alignSelf || 'flex-start';
const hasBorders = styleHasBorders(flattenStyle);
const borderColors = hasBorders && borderColorFromStyle(style);
const backgroundColor = flattenStyle.backgroundColor
? normalizeColor(flattenStyle.backgroundColor)
: null;
const borderStyle = hasBorders && resolveBorderStyle(flattenStyle);
children = ansiAlign(children, { align: textAlign });
children = colorizeText(children, flattenStyle);
if (asArray(flattenStyle.fontWeight).includes('bold')) {
children = chalk.bold(children);
}
if (['italic', 'oblique'].includes(flattenStyle.fontStyle)) {
children = chalk.italic(children);
}
const _textDecorationStyle = asArray(flattenStyle.textDecorationStyle);
if (_textDecorationStyle.includes('underline')) {
children = chalk.underline(children);
}
if (_textDecorationStyle.includes('line-through')) {
children = chalk.strikethrough(children);