Skip to content

Commit

Permalink
feat: support config columns
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jun 24, 2021
1 parent 9694cd9 commit e09f702
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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

0 comments on commit e09f702

Please sign in to comment.