Skip to content

Commit 8c6aec5

Browse files
committed
build examples multiple time to get more consistent timings
1 parent 36ab982 commit 8c6aec5

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

‎examples/build-common.js‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@ var extraArgs = "";
1010

1111
var targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js";
1212
var displayReasons = global.NO_REASONS ? "" : " --display-reasons";
13-
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --output-public-path \"js/\" -p " + extraArgs + targetArgs, function (error, stdout, stderr) {
14-
if(stderr)
15-
console.log(stderr);
16-
if (error !== null)
17-
console.log(error);
18-
var readme = tc(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
19-
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --output-public-path \"js/\" --output-pathinfo " + extraArgs + targetArgs, function (error, stdout, stderr) {
20-
console.log(stdout);
13+
(function doIt(remainingTimes) {
14+
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --output-public-path \"js/\" -p " + extraArgs + targetArgs, function (error, stdout, stderr) {
2115
if(stderr)
2216
console.log(stderr);
2317
if (error !== null)
2418
console.log(error);
25-
readme = tc(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
26-
readme = readme.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
27-
fs.writeFile("README.md", readme, "utf-8", function() {});
19+
var readme = tc(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
20+
cp.exec("node ../../bin/webpack.js" + displayReasons + " --display-chunks --display-modules --display-origins --output-public-path \"js/\" --output-pathinfo " + extraArgs + targetArgs, function (error, stdout, stderr) {
21+
console.log(stdout);
22+
if(stderr)
23+
console.log(stderr);
24+
if (error !== null)
25+
console.log(error);
26+
readme = tc(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
27+
readme = readme.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
28+
fs.writeFile("README.md", readme, "utf-8", function() {});
29+
if(remainingTimes > 1)
30+
doIt(remainingTimes-1);
31+
});
2832
});
29-
});
33+
}(3));

0 commit comments

Comments
 (0)