@bobfrankston/mailx 1.0.27 → 1.0.28
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/bin/mailx.js +21 -6
- package/package.json +1 -1
package/bin/mailx.js
CHANGED
|
@@ -17,14 +17,29 @@ import net from "node:net";
|
|
|
17
17
|
|
|
18
18
|
const PORT = 9333;
|
|
19
19
|
const args = process.argv.slice(2);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
// Normalize: accept both -flag and --flag
|
|
22
|
+
function hasFlag(name) { return args.includes(`-${name}`) || args.includes(`--${name}`); }
|
|
23
|
+
|
|
24
|
+
const serverMode = hasFlag("server");
|
|
25
|
+
const noBrowser = hasFlag("no-browser");
|
|
26
|
+
const verbose = hasFlag("verbose");
|
|
27
|
+
|
|
28
|
+
// Validate arguments
|
|
29
|
+
const knownFlags = ["server", "no-browser", "verbose", "external", "kill", "v", "version"];
|
|
30
|
+
for (const arg of args) {
|
|
31
|
+
const flag = arg.replace(/^--?/, "");
|
|
32
|
+
if (arg.startsWith("-") && !knownFlags.includes(flag)) {
|
|
33
|
+
console.error(`Unknown option: ${arg}`);
|
|
34
|
+
console.error("Usage: mailx [-server] [-verbose] [-kill] [-v] [-no-browser] [-external]");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
|
|
24
39
|
function log(...msg) { if (verbose) console.log("[mailx]", ...msg); }
|
|
25
40
|
|
|
26
41
|
// Kill any running mailx server
|
|
27
|
-
if (
|
|
42
|
+
if (hasFlag("kill")) {
|
|
28
43
|
log("Killing mailx processes...");
|
|
29
44
|
const { execSync } = await import("node:child_process");
|
|
30
45
|
// Kill by port
|
|
@@ -46,7 +61,7 @@ if (args.includes("--kill") || args.includes("-kill")) {
|
|
|
46
61
|
}
|
|
47
62
|
|
|
48
63
|
// Version
|
|
49
|
-
if (
|
|
64
|
+
if (hasFlag("v") || hasFlag("version")) {
|
|
50
65
|
const pkgPath = path.join(import.meta.dirname, "..", "package.json");
|
|
51
66
|
try {
|
|
52
67
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
@@ -89,7 +104,7 @@ async function main() {
|
|
|
89
104
|
|
|
90
105
|
console.log("Starting mailx server...");
|
|
91
106
|
log(`Loading server from: ${path.join(import.meta.dirname, "..", "packages", "mailx-server", "index.js")}`);
|
|
92
|
-
if (
|
|
107
|
+
if (hasFlag("external")) process.argv.push("--external");
|
|
93
108
|
await import("../packages/mailx-server/index.js");
|
|
94
109
|
|
|
95
110
|
if (!noBrowser) {
|