Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time and timeEnd don't respect underline*: false #77

Closed
JasonEtco opened this issue Feb 14, 2019 · 2 comments
Closed

time and timeEnd don't respect underline*: false #77

JasonEtco opened this issue Feb 14, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@JasonEtco
Copy link

Describe the bug

Setting config.underlineLabel does not remove the underline from the time and timeEnd methods.

To Reproduce

Here's the code I'm working with - I've disabled any of the available underline* properties, though underlineLabel should be all that's needed:

// index.js
const { Signale } = require('signale')

const logger = new Signale({
  config: {
    underlineLabel: false,
    underlineMessage: false,
    underlinePrefix: false,
    underlineSuffix: false
  }
})

logger.time('A timer')
logger.timeEnd('A timer')
node index.js

image

Expected behavior

I'd expect the underlineLabel: false setting to apply to the time and timeEnd methods like it does for others.

Looks like that's being set here, without a check for _config.underlineLabel:

https://github.com/klaussinani/signale/blob/ae5701e610034629b44e028010a18b593e0b64c0/signale.js#L325

Technical Info (please complete the following information)

  • OS: MacOS
  • Signale Version: ^1.3.0
  • Node.js Version: 10.13.0

Additional context

I discovered this in my testing of JasonEtco/actions-toolkit#45 - for some reason, the GitHub Actions log display adds additional spaces for labels with an underline:

image

I dug into it and discovered this code. I'm sure its needed for regular terminals/output, but it borks a little in Actions so I just disable underlines entirely (since they wouldn't show up anyway):

https://github.com/klaussinani/signale/blob/ae5701e610034629b44e028010a18b593e0b64c0/signale.js#L212-L216

Let me know if I can clarify anything! Happy to open a PR fixing this if y'all are into it.

@JasonEtco
Copy link
Author

Thanks @klaussinani! ❤️

@klaudiosinani
Copy link
Owner

klaudiosinani commented Feb 15, 2019

Nice catch! Apparently the stream.Writable in-use does not support ANSI escape codes, which combined with the bug/fact that the time() & timeEnd() unaries did not follow the underlineLabel option, resulted in the asymmetrical end-padding of the timer labels. Setting the underlineLabel option to false should now resolve the issue and display the labels as expected. Also, in the upcoming releases, it is planned for signale to automatically detect if ANSI codes are supported at all, and if not, to completely avoid using them. Thank you a lot for taking the time to report the issue! : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants