Skip to content

Commit 1263fc1

Browse files
author
Pooya Parsa
committed
feat: options.buildTitle & consistent number of output lines
1 parent 3df1c38 commit 1263fc1

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ A function that will be called when **all** builds are finished.
123123

124124
This function can optionally return `false` as a signal to stop rendering and printing profile stats.
125125

126+
### `buildTitle`
127+
- Default: `BUILDING`
128+
126129
<h2 align="center">Maintainers</h2>
127130

128131
<table>

kitchen-sync/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ module.exports = {
2222
color: 'yellow',
2323
showCursor: true,
2424
profile: true,
25-
clear: true,
25+
clear: !true,
2626
name: 'webpack-bar',
27+
buildTitle: 'Wait',
2728
}),
2829
],
2930
};

src/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const defaults = {
2424
showCursor: false,
2525
enabled: process.stdout.isTTY && !isCI,
2626
done: null,
27+
buildTitle: 'BUILDING',
2728
};
2829

2930
export default class WebpackBarPlugin extends webpack.ProgressPlugin {
@@ -157,13 +158,21 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin {
157158
);
158159
});
159160

160-
if (someRunning) {
161-
const title = ` ${chalk.bgBlue.black(' BUILDING ')}`;
162-
this.logUpdate(`\n${title}\n\n${lines.join('\n\n')}`);
163-
} else if (shouldClear) {
161+
if (shouldClear && !someRunning) {
164162
this.logUpdate.clear();
163+
return;
164+
}
165+
166+
const lLines = lines.join('\n\n');
167+
168+
if (this.options.buildTitle) {
169+
const title = someRunning
170+
? ` ${chalk.bgBlue.black(` ${this.options.buildTitle} `)}`
171+
: '';
172+
173+
this.logUpdate(`\n${title}\n\n${lLines}`);
165174
} else {
166-
this.logUpdate(`\n\n${lines.join('\n\n')}`);
175+
this.logUpdate(`\n${lLines}`);
167176
}
168177
}
169178
}

0 commit comments

Comments
 (0)