8000 getAvailableWidth() should work without a width · Issue #60 · tecfu/tty-table · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

getAvailableWidth() should work without a width #60

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

Closed
mscalora opened this issue Mar 6, 2020 · 1 comment
Closed

getAvailableWidth() should work without a width #60

mscalora opened this issue Mar 6, 2020 · 1 comment

Comments

@mscalora
Copy link
Contributor
mscalora commented Mar 6, 2020

Problem Summary

getAvailableWidth() should work without a width

This works:
node -e 'T=require("tty-table"); console.log(T([["a","b"]]).render())'

This now throws exception:
node -e 'T=require("tty-table"); console.log(T([["a","b"]]).render())' >/tmp/test.txt

Expected Result (screen shot if possible)

A reasonable table rendering

Should treat width as infinite (fit content) unless % columns are uses, then a reasonable default like 100 should be used.

Actual Result (screen shot if possible)

 node -e 'T=require("tty-table"); console.log(T([["a","b"]]).render())' >/tmp/test.txt

.../node_modules/tty-table/src/format.js:70
  throw new Error("Cannot auto discover available table width. Set table `width` option or export the environment variable COLUMNS")
  ^

Error: Cannot auto discover available table width. Set table `width` option or export the environment variable COLUMNS
    at getAvailableWidth (.../node_modules/tty-table/src/format.js:70:9)
    at Object.module.exports.getColumnWidths (.../node_modules/tty-table/src/format.js:207:26)
    at Object.module.exports.stringifyData (.../node_modules/tty-table/src/render.js:31:78)
    at Array.Factory.tableObject.render (.../node_modules/tty-table/src/factory.js:121:27)
    at [eval]:1:52
    at Script.runInThisContext (vm.js:116:20)
    at Object.runInThisContext (vm.js:306:38)
    at Object.<anonymous> ([eval]-wrapper:9:26)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at evalScript (internal/process/execution.js:80:25)

Environment Information

  • OS: Mac

  • Terminal Emulator: iTerm

Steps to Reproduce

  1. node -e 'T=require("tty-table"); console.log(T([["a","b"]]).render())' >/tmp/test.txt
@tecfu tecfu closed this as completed in fec5aae Mar 6, 2020
@tecfu
Copy link
Owner
tecfu commented Mar 6, 2020

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0