ts-prune
ts-prune copied to clipboard
[FEATURE] Add colour to the terminal output
When lots of items are outputted in the cli, I find they can be difficult to separate out easily by eye.
My initial thought was to separate out the following items by colour (with 1 extra feature):
- file name (e.g. blue)
- line number (e.g. yellow)
- exported name (
myObj1
) (e.g. green) - (new) type of export (
const
,interface
,type
) (runtime vs build time) (e.g. red for runtime, purple for buildtime)
After some light digging, the (new) type information felt like a fair amount of extra work as ts-prune
doesn't appear to be concerned about that, so I thought I'd add chalk
to the outputs, link locally, and raise a proposal PR here.
However, whilst I get additional text being output during testing, I get no colouring.
I'm using Node 14.17.0
, Chalk 4
, yarn link
to symlink and npm link ts-prune
, then running as an npm script in another repo.
The fact I'm getting additional text output indicates the yarn/npm link
is working, but chalk
is not... very strange
// presenter.ts
import chalk from 'chalk';
....
// This had no affect
const formatOutput = (file: string, result: ResultSymbol) => {
const {name, line, usedInModule} = result;
return `${chalk.blue(file)}:${chalk.yellow(line)} - ${chalk.green(name)}` + (usedInModule ? USED_IN_MODULE : '');
}
// runner.ts
...
// I then attempted this on the entire output, no affect
filterIgnored.forEach(value => {
output(chalk.blue(value), 'changed');
});
// I then attempted this on the entire output for sanity, no affect
filterIgnored.forEach(value => {
console.log(chalk.blue(value), 'changed');
});
console.log(chalk.red('test'))
Any thoughts @nadeesha ? Have you tried colouring here before? 👋 thanks for providing this package
Thanks @rubengmurray. I haven't played around with colors, as I've mainly intended this to be a quick CI check. But I'd happily accept a PR if you've got one.
I managed to get it working... The lack of visibility was based on piping logic applied e.g. ts-prune | grep -v....
PR with code here: https://github.com/nadeesha/ts-prune/pull/180 Piping reference here: https://stackoverflow.com/a/48649918/10732370
Gentle nudge on this @nadeesha - PR is ready if you'd like to give your opinion?
Stale issue message
#180 was merged but I can't see that it's been published to npm
Stale issue message
@nadeesha looks like this hasn't made it to npm
. Could you publish?
Stale issue message