forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-common.js
More file actions
41 lines (39 loc) · 1.55 KB
/
build-common.js
File metadata and controls
41 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var cp = require('child_process');
var tc = require("./template-common");
var Stats = require("../lib/Stats");
// var webpackGraph = require("webpack-graph");
var fs = require("fs");
var path = require("path");
var extraArgs = "";
cp.exec("node ../../bin/webpack.js --display-reasons --display-chunks --optimize-minimize "+extraArgs+" ./example.js js/output.js", function (error, stdout, stderr) {
if(stderr)
console.log(stderr);
if (error !== null)
console.log(error);
var readme = tc(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
cp.exec("node ../../bin/webpack.js --display-reasons --display-chunks --output-pathinfo "+extraArgs+" ./example.js js/output.js", function (error, stdout, stderr) {
console.log(stdout);
if(stderr)
console.log(stderr);
if (error !== null)
console.log(error);
// var stats = JSON.parse(stdout);
// var formatedStats = Stats.jsonToString(stats, {
// context: process.cwd(),
// verbose: true
// });
// var filenameShortener = createFilenameShortener(process.cwd());
readme = tc(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
readme = readme.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
fs.writeFile("README.md", readme, "utf-8", function() {});
// fs.writeFile("graph.svg", webpackGraph(stats, {
// nameShortener: filenameShortener,
// width: 500,
// height: 300
// }), "utf-8", function() {});
});
});