@theme-json/validate
Version:
Validate theme.json files when using @theme-json/create
20 lines (19 loc) • 479 B
JavaScript
/**
* External dependencies
*/
import _ from 'lodash';
import pc from 'picocolors';
export function errorsText(errors) {
if (!errors || errors.length === 0) {
return 'No errors';
}
return (errors
.map((err) => {
if (!_.isEmpty(err.instancePath)) {
return `${err.instancePath} ${err.message}`;
}
return err.message;
})
.reduce((text, msg) => `${text}${pc.red('error')} ${msg}\n`, '') ||
'');
}