chalk/wrap-ansi
The issue has been solved
leading space removed when line starts with ansi escape #27
also posted onGitHub
const chalk = require('chalk');
const wrapAnsi = require('wrap-ansi');
const s = chalk.bgGreen(` ${chalk.black('OK')} `);
console.log(s);
console.log(wrapAnsi(s, 100, { trim: false }));