@funnycaptcha/cli 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +23 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -168,7 +168,6 @@ function openBrowser(url) {
|
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
-
var port = 3e3;
|
|
172
171
|
var server = createServer((req, res) => {
|
|
173
172
|
if (req.url === "/" || req.url === "/index.html") {
|
|
174
173
|
const html = getDemoHTML();
|
|
@@ -179,18 +178,29 @@ var server = createServer((req, res) => {
|
|
|
179
178
|
res.end("Not found");
|
|
180
179
|
}
|
|
181
180
|
});
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
function startOnAvailablePort(startPort) {
|
|
182
|
+
server.once("error", (err) => {
|
|
183
|
+
if (err.code === "EADDRINUSE" && startPort < 3100) {
|
|
184
|
+
startOnAvailablePort(startPort + 1);
|
|
185
|
+
} else {
|
|
186
|
+
console.error(`\u65E0\u6CD5\u542F\u52A8\u670D\u52A1\u5668: ${err.message}`);
|
|
187
|
+
process.exit(1);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
server.listen(startPort, () => {
|
|
191
|
+
const url = `http://localhost:${startPort}`;
|
|
192
|
+
console.log("");
|
|
193
|
+
console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
|
|
194
|
+
console.log(" \u2551 FunnyChapter CLI Demo \u2551");
|
|
195
|
+
console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
|
|
196
|
+
console.log("");
|
|
197
|
+
console.log(` \u279C Demo: ${url}`);
|
|
198
|
+
console.log(` \u279C \u6309 Ctrl+C \u9000\u51FA`);
|
|
199
|
+
console.log("");
|
|
200
|
+
openBrowser(url);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
startOnAvailablePort(3e3);
|
|
194
204
|
process.on("SIGINT", () => {
|
|
195
205
|
console.log("\n \u518D\u89C1\uFF01");
|
|
196
206
|
server.close();
|