Skip to content

Commit 802dd7c

Browse files
committed
updated optimist to yargs
1 parent dbb09b4 commit 802dd7c

File tree

2 files changed

+86
-45
lines changed

2 files changed

+86
-45
lines changed

bin/webpack-dev-server.js

Lines changed: 83 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,91 @@ try {
1616
var Server = require("../lib/Server");
1717
var webpack = require("webpack");
1818

19-
var optimist = require("optimist")
20-
21-
.usage("webpack-dev-server " + require("../package.json").version + "\n" +
22-
"Usage: http://webpack.github.io/docs/webpack-dev-server.html")
23-
24-
.boolean("lazy").describe("lazy")
25-
26-
.boolean("stdin").describe("stdin", "close when stdin ends")
27-
28-
.boolean("info").describe("info").default("info", true)
29-
30-
.boolean("quiet").describe("quiet")
31-
32-
.boolean("inline").describe("inline", "Inline the webpack-dev-server logic into the bundle.")
33-
34-
.boolean("https").describe("https")
35-
36-
.string("key").describe("key", "Path to a SSL key.")
37-
38-
.string("cert").describe("cert", "Path to a SSL certificate.")
39-
40-
.string("cacert").describe("cacert", "Path to a SSL CA certificate.")
41-
42-
.string("content-base").describe("content-base", "A directory or URL to serve HTML content from.")
43-
44-
.string("content-base-target").describe("content-base-target", "Proxy requests to this target.")
45-
46-
.boolean("history-api-fallback").describe("history-api-fallback", "Fallback to /index.html for Single Page Applications.")
47-
48-
.boolean("compress").describe("compress", "enable gzip compression")
49-
50-
.boolean("open").describe("open", "Open default browser")
51-
52-
.describe("port", "The port").default("port", 8080)
53-
54-
.describe("public", "The public hostname/ip address of the server")
55-
56-
.describe("host", "The hostname/ip address the server will bind to").default("host", "localhost");
57-
58-
require("webpack/bin/config-optimist")(optimist);
19+
var yargs = require("yargs")
20+
.usage("webpack-dev-server " + require("../package.json").version + "\n" +
21+
"Usage: http://webpack.github.io/docs/webpack-dev-server.html");
22+
23+
require("webpack/bin/config-yargs")(yargs);
24+
25+
var DISPLAY_GROUP = "Stats options:";
26+
var SSL_GROUP = "SSL options:";
27+
var CONNECTION_GROUP = "Connection options:";
28+
var RESPONSE_GROUP = "Response options:";
29+
30+
yargs.options({
31+
"lazy": {
32+
type: "boolean"
33+
},
34+
"stdin": {
35+
type: "boolean",
36+
describe: "close when stdin ends"
37+
},
38+
"open": {
39+
type: "boolean",
40+
describe: "Open default browser"
41+
},
42+
"info": {
43+
type: "boolean",
44+
group: DISPLAY_GROUP
45+
},
46+
"quiet": {
47+
type: "boolean",
48+
group: DISPLAY_GROUP
49+
},
50+
"https": {
51+
type: "boolean",
52+
group: SSL_GROUP
53+
},
54+
"key": {
55+
type: "string",
56+
describe: "Path to a SSL key.",
57+
group: SSL_GROUP
58+
},
59+
"cert": {
60+
type: "string",
61+
describe: "Path to a SSL certificate.",
62+
group: SSL_GROUP
63+
},
64+
"cacert": {
65+
type: "string",
66+
describe: "Path to a SSL CA certificate.",
67+
group: SSL_GROUP
68+
},
69+
"content-base": {
70+
type: "string",
71+
describe: "A directory or URL to serve HTML content from.",
72+
group: RESPONSE_GROUP
73+
},
74+
"history-api-fallback": {
75+
type: "boolean",
76+
describe: "Fallback to /index.html for Single Page Applications.",
77+
group: RESPONSE_GROUP
78+
},
79+
"compress": {
80+
type: "boolean",
81+
describe: "Enable gzip compression",
82+
group: RESPONSE_GROUP
83+
},
84+
"port": {
85+
describe: "The port",
86+
group: CONNECTION_GROUP
87+
},
88+
"public": {
89+
type: "string",
90+
describe: "The public hostname/ip address of the server",
91+
group: CONNECTION_GROUP
92+
},
93+
"host": {
94+
type: "string",
95+
default: "localhost",
96+
describe: "The hostname/ip address the server will bind to",
97+
group: CONNECTION_GROUP
98+
}
99+
});
59100

60-
var argv = optimist.argv;
101+
var argv = yargs.argv;
61102

62-
var wpOpt = require("webpack/bin/convert-argv")(optimist, argv, {
103+
var wpOpt = require("webpack/bin/convert-argv")(yargs, argv, {
63104
outputFilename: "/bundle.js"
64105
});
65106
var firstWpOpt = Array.isArray(wpOpt) ? wpOpt[0] : wpOpt;

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"author": "Tobias Koppers @sokra",
55
"description": "Serves a webpack app. Updates the browser on changes.",
66
"peerDependencies": {
7-
"webpack": ">=1.3.0 <3"
7+
"webpack": ">=2.0.3-beta <3"
88
},
99
"dependencies": {
1010
"compression": "^1.5.2",
1111
"connect-history-api-fallback": "1.1.0",
1212
"express": "^4.13.3",
13-
"optimist": "~0.6.0",
13+
"http-proxy-middleware": "~0.9.1",
1414
"open": "0.0.5",
1515
"serve-index": "^1.7.2",
1616
"sockjs": "^0.3.15",
@@ -19,7 +19,7 @@
1919
"strip-ansi": "^3.0.0",
2020
"supports-color": "^3.1.1",
2121
"webpack-dev-middleware": "^1.4.0",
22-
"http-proxy-middleware": "~0.9.1"
22+
"yargs": "^3.32.0"
2323
},
2424
"devDependencies": {
2525
"beautify-lint": "^1.0.4",

0 commit comments

Comments
 (0)