Skip to content

Commit d01af47

Browse files
bitpshrevenstensberg
authored andcommitted
feat: support --build-delimiter for opt-in output delimiter (#192) (#340)
1 parent e9c6800 commit d01af47

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

bin/process-options.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ module.exports = function processOptions(yargs, argv) {
9898
if (bool) outputOptions.cachedAssets = true;
9999
});
100100

101+
ifArg("build-delimiter", function(value) {
102+
outputOptions.buildDelimiter = value;
103+
});
104+
101105
if (!outputOptions.exclude && !argv["display-modules"])
102106
outputOptions.exclude = [
103107
"node_modules",
@@ -175,8 +179,9 @@ module.exports = function processOptions(yargs, argv) {
175179
);
176180
} else if (stats.hash !== lastHash) {
177181
lastHash = stats.hash;
182+
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : "";
178183
process.stdout.write("\n" + new Date() + "\n" + "\n");
179-
process.stdout.write(stats.toString(outputOptions) + "\n");
184+
process.stdout.write(`${stats.toString(outputOptions)}\n${delimiter}`);
180185
if (argv.s) lastHash = null;
181186
}
182187
if (!options.watch && stats.hasErrors()) {

bin/webpack.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@
203203
group: DISPLAY_GROUP,
204204
describe:
205205
"Controls the output of lifecycle messaging e.g. Started watching files..."
206+
},
207+
"build-delimiter": {
208+
type: "string",
209+
group: DISPLAY_GROUP,
210+
describe: "Display custom text after build output"
206211
}
207212
});
208213

@@ -419,6 +424,10 @@
419424
outputOptions.infoVerbosity = value;
420425
});
421426

427+
ifArg("build-delimiter", function(value) {
428+
outputOptions.buildDelimiter = value;
429+
});
430+
422431
const webpack = require("webpack");
423432

424433
let lastHash = null;
@@ -473,7 +482,8 @@
473482
} else if (stats.hash !== lastHash) {
474483
lastHash = stats.hash;
475484
const statsString = stats.toString(outputOptions);
476-
if (statsString) stdout.write(statsString + "\n");
485+
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : "";
486+
if (statsString) stdout.write(`${statsString}\n${delimiter}`);
477487
}
478488
if (!options.watch && stats.hasErrors()) {
479489
process.exitCode = 2;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "foo";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
3+
module.exports = function testAssertions(code, stdout, stderr) {
4+
const lastLines = stdout.slice(-2);
5+
expect(code).toBe(0);
6+
expect(lastLines[0]).toBe("success");
7+
expect(lastLines[1]).toBe("");
8+
expect(stderr).toHaveLength(0);
9+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--entry ./index.js
2+
--display normal
3+
--build-delimiter success

0 commit comments

Comments
 (0)