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

Support --build-delimiter for opt-in output delimiter #340

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/process-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ module.exports = function processOptions(yargs, argv) {
if (bool) outputOptions.cachedAssets = true;
});

ifArg("build-delimiter", function(value) {
outputOptions.buildDelimiter = value;
});

if (!outputOptions.exclude && !argv["display-modules"])
outputOptions.exclude = [
"node_modules",
Expand Down Expand Up @@ -175,8 +179,9 @@ module.exports = function processOptions(yargs, argv) {
);
} else if (stats.hash !== lastHash) {
lastHash = stats.hash;
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : "";
process.stdout.write("\n" + new Date() + "\n" + "\n");
process.stdout.write(stats.toString(outputOptions) + "\n");
process.stdout.write(`${stats.toString(outputOptions)}\n${delimiter}`);
if (argv.s) lastHash = null;
}
if (!options.watch && stats.hasErrors()) {
Expand Down
12 changes: 11 additions & 1 deletion bin/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@
group: DISPLAY_GROUP,
describe:
"Controls the output of lifecycle messaging e.g. Started watching files..."
},
"build-delimiter": {
type: "string",
group: DISPLAY_GROUP,
describe: "Display custom text after build output"
}
});

Expand Down Expand Up @@ -419,6 +424,10 @@
outputOptions.infoVerbosity = value;
});

ifArg("build-delimiter", function(value) {
outputOptions.buildDelimiter = value;
});

const webpack = require("webpack");

let lastHash = null;
Expand Down Expand Up @@ -473,7 +482,8 @@
} else if (stats.hash !== lastHash) {
lastHash = stats.hash;
const statsString = stats.toString(outputOptions);
if (statsString) stdout.write(statsString + "\n");
const delimiter = outputOptions.buildDelimiter ? `${outputOptions.buildDelimiter}\n` : "";
if (statsString) stdout.write(`${statsString}\n${delimiter}`);
}
if (!options.watch && stats.hasErrors()) {
process.exitCode = 2;
Expand Down
1 change: 1 addition & 0 deletions test/binCases/stats/build-delimiter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "foo";
9 changes: 9 additions & 0 deletions test/binCases/stats/build-delimiter/stdin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

module.exports = function testAssertions(code, stdout, stderr) {
const lastLines = stdout.slice(-2);
expect(code).toBe(0);
expect(lastLines[0]).toBe("success");
expect(lastLines[1]).toBe("");
expect(stderr).toHaveLength(0);
};
3 changes: 3 additions & 0 deletions test/binCases/stats/build-delimiter/test.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--entry ./index.js
--display normal
--build-delimiter success