Skip to content

Commit 2e2cb74

Browse files
committed
beautify bin
1 parent 5f14ee4 commit 2e2cb74

File tree

5 files changed

+66
-122
lines changed

5 files changed

+66
-122
lines changed

bin/config-optimist.js

Lines changed: 46 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,48 @@
11
module.exports = function(optimist) {
22
optimist
3-
4-
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
5-
6-
.string("config").describe("config")
7-
8-
.string("context").describe("context")
9-
10-
.string("entry").describe("entry")
11-
12-
.string("module-bind").describe("module-bind")
13-
14-
.string("module-bind-post").describe("module-bind-post")
15-
16-
.string("module-bind-pre").describe("module-bind-pre")
17-
18-
.string("output-path").describe("output-path")
19-
20-
.string("output-file").describe("output-file")
21-
22-
.string("output-chunk-file").describe("output-chunk-file")
23-
24-
.string("output-named-chunk-file").describe("output-named-chunk-file")
25-
26-
.string("output-source-map-file").describe("output-source-map-file")
27-
28-
.string("output-public-path").describe("output-public-path")
29-
30-
.string("output-jsonp-function").describe("output-jsonp-function")
31-
32-
.boolean("output-pathinfo").describe("output-pathinfo")
33-
34-
.string("output-library").describe("output-library")
35-
36-
.string("output-library-target").describe("output-library-target")
37-
38-
.string("records-input-path").describe("records-input-path")
39-
40-
.string("records-output-path").describe("records-output-path")
41-
42-
.string("records-path").describe("records-path")
43-
44-
.string("define").describe("define")
45-
46-
.string("target").describe("target")
47-
48-
.boolean("cache").describe("cache").default("cache", true)
49-
50-
.boolean("watch").alias("watch", "w").describe("watch")
51-
52-
.describe("watch-aggregate-timeout")
53-
54-
.describe("watch-poll")
55-
56-
.boolean("hot").alias("hot", "h").describe("hot")
57-
58-
.boolean("debug").describe("debug")
59-
60-
.string("devtool").describe("devtool")
61-
62-
.boolean("progress").describe("progress")
63-
64-
.string("resolve-alias").describe("resolve-alias")
65-
66-
.string("resolve-loader-alias").describe("resolve-loader-alias")
67-
68-
.describe("optimize-max-chunks")
69-
70-
.describe("optimize-min-chunk-size")
71-
72-
.boolean("optimize-minimize").describe("optimize-minimize")
73-
74-
.boolean("optimize-occurence-order").describe("optimize-occurence-order")
75-
76-
.boolean("optimize-dedupe").describe("optimize-dedupe")
77-
78-
.string("prefetch").describe("prefetch")
79-
80-
.string("provide").describe("provide")
81-
82-
.boolean("labeled-modules").describe("labeled-modules")
83-
84-
.string("plugin").describe("plugin")
85-
86-
.boolean("bail").describe("bail")
87-
88-
.boolean("profile").describe("profile")
89-
90-
.boolean("d").describe("d", "shortcut for --debug --devtool sourcemap --output-pathinfo")
91-
92-
.boolean("p").describe("p", "shortcut for --optimize-minimize");
93-
};
3+
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
4+
.string("config").describe("config")
5+
.string("context").describe("context")
6+
.string("entry").describe("entry")
7+
.string("module-bind").describe("module-bind")
8+
.string("module-bind-post").describe("module-bind-post")
9+
.string("module-bind-pre").describe("module-bind-pre")
10+
.string("output-path").describe("output-path")
11+
.string("output-file").describe("output-file")
12+
.string("output-chunk-file").describe("output-chunk-file")
13+
.string("output-named-chunk-file").describe("output-named-chunk-file")
14+
.string("output-source-map-file").describe("output-source-map-file")
15+
.string("output-public-path").describe("output-public-path")
16+
.string("output-jsonp-function").describe("output-jsonp-function")
17+
.boolean("output-pathinfo").describe("output-pathinfo")
18+
.string("output-library").describe("output-library")
19+
.string("output-library-target").describe("output-library-target")
20+
.string("records-input-path").describe("records-input-path")
21+
.string("records-output-path").describe("records-output-path")
22+
.string("records-path").describe("records-path")
23+
.string("define").describe("define")
24+
.string("target").describe("target")
25+
.boolean("cache").describe("cache").default("cache", true)
26+
.boolean("watch").alias("watch", "w").describe("watch")
27+
.describe("watch-aggregate-timeout")
28+
.describe("watch-poll")
29+
.boolean("hot").alias("hot", "h").describe("hot")
30+
.boolean("debug").describe("debug")
31+
.string("devtool").describe("devtool")
32+
.boolean("progress").describe("progress")
33+
.string("resolve-alias").describe("resolve-alias")
34+
.string("resolve-loader-alias").describe("resolve-loader-alias")
35+
.describe("optimize-max-chunks")
36+
.describe("optimize-min-chunk-size")
37+
.boolean("optimize-minimize").describe("optimize-minimize")
38+
.boolean("optimize-occurence-order").describe("optimize-occurence-order")
39+
.boolean("optimize-dedupe").describe("optimize-dedupe")
40+
.string("prefetch").describe("prefetch")
41+
.string("provide").describe("provide")
42+
.boolean("labeled-modules").describe("labeled-modules")
43+
.string("plugin").describe("plugin")
44+
.boolean("bail").describe("bail")
45+
.boolean("profile").describe("profile")
46+
.boolean("d").describe("d", "shortcut for --debug --devtool sourcemap --output-pathinfo")
47+
.boolean("p").describe("p", "shortcut for --optimize-minimize");
48+
};

bin/convert-argv.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ module.exports = function(optimist, argv, convertOptions) {
2828
}
2929

3030
var configPath, ext;
31-
var extensions = Object.keys(interpret.extensions).sort(function(a, b){
31+
var extensions = Object.keys(interpret.extensions).sort(function(a, b) {
3232
return a.length - b.length;
3333
});
3434

35-
if (argv.config) {
35+
if(argv.config) {
3636
configPath = path.resolve(argv.config);
37-
for (var i = extensions.length - 1; i >= 0; i--) {
37+
for(var i = extensions.length - 1; i >= 0; i--) {
3838
var tmpExt = extensions[i];
39-
if (configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1){
39+
if(configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1) {
4040
ext = tmpExt;
4141
break;
4242
}
43-
};
44-
if (!ext) {
43+
}
44+
if(!ext) {
4545
ext = path.extname(configPath);
4646
}
4747
} else {
4848
for(var i = 0; i < extensions.length; i++) {
49-
var webpackConfig = path.resolve('webpack.config' + extensions[i]);
49+
var webpackConfig = path.resolve("webpack.config" + extensions[i]);
5050
if(fs.existsSync(webpackConfig)) {
5151
ext = extensions[i];
5252
configPath = webpackConfig;
@@ -58,8 +58,8 @@ module.exports = function(optimist, argv, convertOptions) {
5858
if(configPath) {
5959

6060
function registerCompiler(moduleDescriptor) {
61-
if (moduleDescriptor) {
62-
if(typeof(moduleDescriptor) == "string") {
61+
if(moduleDescriptor) {
62+
if(typeof moduleDescriptor === "string") {
6363
require(moduleDescriptor);
6464
} else if(!Array.isArray(moduleDescriptor)) {
6565
moduleDescriptor.register(require(moduleDescriptor.module));
@@ -98,7 +98,7 @@ module.exports = function(optimist, argv, convertOptions) {
9898
options.context = process.cwd();
9999
}
100100

101-
if(argv["watch"]) {
101+
if(argv.watch) {
102102
// TODO remove this in next major version
103103
if(options.watch && typeof options.watch === "object") {
104104
console.warn("options.watch is deprecated: Use 'options.watchOptions' instead");
@@ -197,7 +197,7 @@ module.exports = function(optimist, argv, convertOptions) {
197197
var args = null;
198198
try {
199199
var p = name && name.indexOf("?");
200-
if (p > -1) {
200+
if(p > -1) {
201201
args = loadUtils.parseQuery(name.substring(p));
202202
name = name.substring(0, p);
203203
}
@@ -364,7 +364,8 @@ module.exports = function(optimist, argv, convertOptions) {
364364
ifBooleanArg("progress", function() {
365365
var ProgressPlugin = require("../lib/ProgressPlugin");
366366
ensureArray(options, "plugins");
367-
var chars = 0, lastState, lastStateTime;
367+
var chars = 0,
368+
lastState, lastStateTime;
368369
options.plugins.push(new ProgressPlugin(function(percentage, msg) {
369370
var state = msg;
370371
if(percentage < 1) {
@@ -397,6 +398,7 @@ module.exports = function(optimist, argv, convertOptions) {
397398
goToLineStart(msg);
398399
process.stderr.write(msg);
399400
}));
401+
400402
function goToLineStart(nextMessage) {
401403
var str = "";
402404
for(; chars > nextMessage.length; chars--) {
@@ -518,6 +520,7 @@ module.exports = function(optimist, argv, convertOptions) {
518520
};
519521
}
520522
ensureObject(options, "entry");
523+
521524
function addTo(name, entry) {
522525
if(options.entry[name]) {
523526
if(!Array.isArray(options.entry[name])) {

bin/webpack.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,21 @@ var optimist = require("optimist")
1919
require("./config-optimist")(optimist);
2020

2121
optimist
22-
2322
.boolean("json").alias("json", "j").describe("json")
24-
2523
.boolean("colors").alias("colors", "c").describe("colors")
26-
2724
.string("sort-modules-by").describe("sort-modules-by")
28-
2925
.string("sort-chunks-by").describe("sort-chunks-by")
30-
3126
.string("sort-assets-by").describe("sort-assets-by")
32-
3327
.boolean("hide-modules").describe("hide-modules")
34-
3528
.string("display-exclude").describe("display-exclude")
36-
3729
.boolean("display-modules").describe("display-modules")
38-
3930
.boolean("display-chunks").describe("display-chunks")
40-
4131
.boolean("display-error-details").describe("display-error-details")
42-
4332
.boolean("display-origins").describe("display-origins")
44-
4533
.boolean("display-cached").describe("display-cached")
46-
4734
.boolean("display-cached-assets").describe("display-cached-assets")
48-
4935
.boolean("display-reasons").alias("display-reasons", "verbose").alias("display-reasons", "v").describe("display-reasons");
5036

51-
5237
var argv = optimist.argv;
5338

5439
var options = require("./convert-argv")(optimist, argv);
@@ -155,6 +140,7 @@ var webpack = require("../lib/webpack.js");
155140
Error.stackTraceLimit = 30;
156141
var lastHash = null;
157142
var compiler = webpack(options);
143+
158144
function compilerCallback(err, stats) {
159145
if(!options.watch) {
160146
// Do not keep cache anymore

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"component-webpack-plugin": "~0.2.0",
2929
"coveralls": "^2.11.2",
3030
"css-loader": "~0.15.0",
31-
"diff": "^1.4.0",
32-
"eslint": "^0.24.0",
31+
"diff": "^2.0.2",
32+
"eslint": "^1.1.0",
3333
"eslint-plugin-nodeca": "^1.0.3",
3434
"express": "~4.13.1",
3535
"extract-text-webpack-plugin": "~0.8.0",
@@ -76,7 +76,7 @@
7676
"pretest": "npm run lint && npm run beautify-lint",
7777
"test": "mocha",
7878
"travis": "npm run cover -- --report lcovonly",
79-
"lint": "eslint lib",
79+
"lint": "eslint lib bin",
8080
"beautify-lint": "node ./scripts/beautify-check",
8181
"beautify": "node ./scripts/beautify-rewrite",
8282
"precover": "npm run lint && npm run beautify-lint",

scripts/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
exports.beautify = {
2-
files: "{{lib,hot,scripts}/**/*.js,benchmark/*.js}"
2+
files: "{{lib,hot,scripts,bin}/**/*.js,benchmark/*.js}"
33
};

0 commit comments

Comments
 (0)