Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import supportsColor from 'supports-color';
if (supportsColor) {
console.log('Terminal supports color');
if (supportsColor.hasBasic) {
const level: number = supportsColor.level;
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
(supportsColor.level: string);
}
export = (done: any) => {
let bannerPath = join(Config.TOOLS_DIR, 'config', 'ycbanner.txt'); // #YC#
if (require('supports-color').has256) {
bannerPath = join(Config.TOOLS_DIR, 'config', 'ycbanner-256.txt'); // #YC#
}
readFile(bannerPath, (e, content) => {
if (!e) {
console.log(util.colors.blue(content.toString()));
}
done();
});
};
export = (done: any) => {
let bannerPath = join(Config.TOOLS_DIR, 'config', 'banner.txt');
const colors = require('supports-color');
if (colors.has256 || colors.stdout.has256) {
bannerPath = join(Config.TOOLS_DIR, 'config', 'banner-256.txt');
}
readFile(bannerPath, (e, content) => {
if (!e) {
console.log(util.colors.green(content.toString()));
}
done();
});
};
colors.heroku = s => {
if (!chalk.enabled) return s
let supports = require('supports-color')
if (!supports) return s
supports.has256 = supports.has256 || (process.env.TERM || '').indexOf('256') !== -1
return supports.has256 ? '\u001b[38;5;104m' + s + styles.reset.open : chalk.magenta(s)
}