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

feat: support config columns #52

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const sliceAnsi = require('slice-ansi');

const defaultTerminalHeight = 24;

const getWidth = stream => {
const getWidth = (stream, defaultColumns) => {
const {columns} = stream;

if (!columns) {
return 80;
return defaultColumns;
}

return columns;
Expand All @@ -31,9 +31,9 @@ const fitToTerminalHeight = (stream, text) => {
text.length);
};

const main = (stream, {showCursor = false} = {}) => {
const main = (stream, {showCursor = false, columns = 80} = {}) => {
let previousLineCount = 0;
let previousWidth = getWidth(stream);
let previousWidth = getWidth(stream, columns);
let previousOutput = '';

const render = (...args) => {
Expand Down
16 changes: 16 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ const log = logUpdate.create(process.stdout, {
});
```

##### columns

Type: `number`\
Default: `80`

Default columns of stream.

```js
const logUpdate = require('log-update');

// The max width of columns will be set to 120
const log = logUpdate.create(process.stdout, {
columns: 120
});
```

## Examples

- [listr](https://github.com/SamVerschueren/listr) - Uses this module to render an interactive task list
Expand Down